Extension talk:Data Transfer

Adding prefix to title?
I'm looking to import a CSV file with at least 1,000 entries in it, but I want them to go into a separate namespace and provide transclusion only. Is there any way to achieve this?


 * What do you mean by transclusion? Yaron Koren (talk) 14:35, 18 October 2019 (UTC)


 * Like this: Transclusion. I don't want the actual page searchable in the wiki, but I want the data available for other pages to use. So i'm creating a custom namespace for "Asset" where all the assets data will get dumped into, and stored into cargo tables and then the actual article pages will run a query to find their relevant assets data.


 * Oh, I thought the transclusion thing was related to the data transfer part. You just need to add the namespace to every title in the CSV file. There are various ways to do that - one is by editing the data in a spreadsheet, then saving it back to CSV. Within a spreadsheet, you can create a separate column with just the namespace (and colon), then merge that column and the title column into one. Yaron Koren (talk) 16:47, 18 October 2019 (UTC)


 * That's what I was afraid of, was hoping I could apply something at time of import. But I think I can get awk to do what I need it to do. Thanks!

error with MW 1.34
/Special:ImportCSV Error from line 54 of ...extensions/DataTransfer/specials/DT_ImportCSV.php: Cannot access private property ImportStreamSource::$mHandle

Backtrace:


 * 1) 0 ...extensions/DataTransfer/specials/DT_ImportCSV.php(29): DTImportCSV->importFromUploadAndModifyPages
 * 2) 1 ...includes/specialpage/SpecialPage.php(575): DTImportCSV->execute
 * 3) 2 ...includes/specialpage/SpecialPageFactory.php(611): SpecialPage->run
 * 4) 3 ...includes/MediaWiki.php(296): MediaWiki\Special\SpecialPageFactory->executePath
 * 5) 4 ...includes/MediaWiki.php(900): MediaWiki->performRequest
 * 6) 5 ...includes/MediaWiki.php(527): MediaWiki->main
 * 7) 6 ...index.php(44): MediaWiki->run
 * 8) 7 {main}


 * Sorry about that - I just checked in what I think is a fix for this. Please let me know if there's still a problem! Yaron Koren (talk) 22:48, 7 January 2020 (UTC)


 * Thanks. I am now able to import the data, but there's an unrelated problem having to do with LF handling.Acnetj (talk) 00:59, 8 January 2020 (UTC)

LF handling
With the older version. a CSV field can include a new line (LF) and it is not parsed as a separate entry (it is to include free text for the wiki which has multiple lines. The current master (fixing the error above) however handles LF as if it is CRLF.

I changed this on DT_ImportCSV.php and the handling is correct: line 133: 		$table = str_getcsv( $csvString, "\n" );

line 133: 		$table = str_getcsv( $csvString, "\r\n" ); But it ignored extra LF on the field. Acnetj (talk) 01:31, 8 January 2020 (UTC)
 * This fix works for me in this particular instance (because I use control-enter for extra line in LibreOffice). I don't know for other instances. I think it should somehow respect the double quotation marks like for the commas.

Acnetj (talk) 01:52, 8 January 2020 (UTC)


 * Sorry about that! What a strange bug in PHP. I just checked in code that I think works better. Yaron Koren (talk) 19:35, 8 January 2020 (UTC)


 * I am getting

Unable to construct a valid title from "". with the latest update. Acnetj (talk) 02:13, 10 January 2020 (UTC)


 * What encoding is the file in, do you know? Yaron Koren (talk) 04:12, 10 January 2020 (UTC)
 * UTF-8. Just a simple file with one line of data plus header. Acnetj (talk) 19:18, 10 January 2020 (UTC)
 * I can't reproduce that problem. Was this exact file working before? Yaron Koren (talk) 20:21, 10 January 2020 (UTC)
 * Sorry I just found it was a problem on my end. Just bad data. Things are working as it should for now.Acnetj (talk) 21:40, 10 January 2020 (UTC)
 * Great, that's a relief! Yaron Koren (talk) 21:43, 10 January 2020 (UTC)

Problem with overwriting fields of the template
MW 1.31, using UTF-16 LE with signature CSV Import

I try to update some content for a specific template.

For example, existing content for page "Acilius":

Or it could look like this:

To update I use this file content (using option "Overwrite only fields contained in the file", other templates also existed in page):

Title,WoodhouseENELnames[Text] "Acilius","Ἀκύλιος, ὁ."

Result:

(I deliberately added space in the middle of each entity so that it will not get parsed here) So, for some strange reason the thumbnail, link and old text are maintained and some text is corrupted and/or turned into html entities. When I select "Overwrite existing content" or "Append to existing content" no such problems exist, but I cannot do that as other templates exist in those pages.

I suspect that the "|link=" bit is parsed as an extra field, when in fact it isn't.

I even tried removing first this bit from the content:

And then trying the import. And then I got this error:

Error: the column 0 header, 'ÿþTitle', must be either 'Title', 'Free Text' or of the form 'template_name[field_name]'

Edit: I have managed to partly resolve the import into field corruption by commenting out some regexes in: DataTransfer\includes\DT_PageStructure.php

// $page_contents = preg_replace( '//', '&# 123;&# 123;$1&# 125;&# 125;', $page_contents ); // escape out transclusions, and calls like "DEFAULTSORT" // $page_contents = preg_replace( '//', '&# 123;&# 123;$1&# 125;&# 125;', $page_contents );

But still, I cannot find how to stop breaking the line with the image link from

To

Or when the existing text contains instances like compare They get turned into

compare or even mixed with other words.

For example this text:

leave in the lurch: P. and V. λείπω, λείπειν

Looked like this when imported:

leave in the lurch: προλείπειν, ἀμείβειν (Plat. but rare P.), V. ἐξαμείβειν, ἐκλιμπάνειν.

So I am guessing that there is some pre-processing going on before the import which is affected by what the currently existing text looks like, which is quite strange.