Help talk:CSV format

From semantic-mediawiki.org

Talk pages on this wiki should primarily be used to address possible mistakes as well as missing and superseded information in the documentation.
In case you are seeking support concerning individual questions, please have a look at this page. The Semantic MediaWiki user mailing list is always a good idea for seeking help.

Text included in CSV format[edit]

How can I get the article text included in a query using CSV format?

In case it is stored in a property just query for this one too. Otherwise it is not possible. Cheers --[[kgh]] 13:02, 8 February 2012 (CET)

Number of results[edit]

Forgive my ignorance but I only seem to get 21 results when I know there are many more.

Thanks --Jeremy.Osborn 14:30, 31 May 2012 (CEST)

Hi Jeremy, this may have several reasons, e.g. you are sorting by a property not annotated on all pages you wish to see. Also, it may already come from your query description. I think you should play around with your query to see what is happening when changing "variables". Cheers --[[kgh]] 23:10, 31 May 2012 (CEST) PS The mailing list is the better place to ask questions about SMW.

Contents

Thread titleRepliesLast modified
'filename' parameter not working322:55, 29 January 2016
Limit ignored in CSV export?411:59, 8 April 2015
Problems with umlaut511:58, 17 March 2015
URL length in result link009:49, 23 October 2014
How do you specify tab as a separator?015:28, 26 February 2013

'filename' parameter not working

Trying to get the output file to be something other than results(#).csv and the parameter isn't helping... e.g., CSV isn't giving me "majors.csv".

(Doing this on referata.com)

22:12, 29 January 2016

Sorry, didn't realize the ask wouldn't display...

{{#ask:[[Category:Students]]|?Has Credits=Credits earned|?Has Major=Majors|?Has Grad Term=Due to graduate|headers=plain|format=csv|filename=majors.csv}}

22:13, 29 January 2016

I think this was indeed an issue with SMW 1.8 and lower. However, I believe that this is working with the recent version. You could verify on http://sandbox.semantic-mediawiki.org/ to be sure.

22:50, 29 January 2016

Now I know why this appeard so familiar to me. Tested this end of December 2015: CSV filename test. Yes it is working now so upgrading the software is your friend.

22:55, 29 January 2016
 
 
 

Limit ignored in CSV export?

Hello,

See https://bugzilla.wikimedia.org/show_bug.cgi?id=48756

Limit value is ignored in query--so results exported to CSV are limited to 100. However, I have about 500 total values that I wish to export, that are available.

Using SMW 1.8.0.5.

Any suggestions?

22:08, 7 November 2013

Ditto. I cannot get back more than 100 rows of data ... If only I knew PHP better ...

07:54, 5 December 2013

I found the relevant PHP code anyway and changed it from 100 to 1000. It is located within SemanticMediawiki/includes/queryprinters/SMW_QP_CSV.php line 128 (or thereabouts, depending on SMW version)

08:23, 5 December 2013

I found the section in SemanticMediawiki/includes/queryprinters/SMW_QP_CSV.php and changed it from 100 to 1000, but it had no effect. Still only 100 are exported...

09:14, 13 June 2014

See now https://github.com/SemanticMediaWiki/SemanticMediaWiki/issues/242 although I'm not sure if there was a fix. Anyone?

(The issue was also reported at https://github.com/SemanticMediaWiki/SemanticResultFormats/issues/42 but deferred to SMW core)

11:59, 8 April 2015
 
 
 
 

Problems with umlaut

Hi, i am using SMW 1.8 and when I export data that contains an umlaut (ä,ö,ü,..) as CSV and open this file in Excel directly, then these characters are not displayed correctly. Instead I see things like "ÄÖÜäöüß". Is UTF8 support broken for SMW 1.8?

17:41, 6 June 2013

Heiya Basil, I suspect that the problem is not SMW but Excel. Even though you export the file in UTF-8 Excel opens the file in Latin. What does e.g. Libre office do with the same file? Cheers

19:07, 6 June 2013

I've run into the same issue as well and have a patch which at least fixes it for me. I see that SMW exports the data as UTF-8, but Excel can't figure that out, and it's a bit of a hassle to import the data in the correct format. The solution to this is to add the UTF-8 byte order mark to the beginning of the string to be returned (see http://roosmaa.net/importing-utf-8-csvs-in-excel/). Also setting the delimiter to a semicolon makes Excel happy.

What I've done is add the BOM around line 106 of includes/queryprinters/SMW_QP_CSV.php:

$result .= stream_get_contents( $csv );
// Add the UTF-8 byte order mark (BOM) so that Excel can read this in as UTF-8
$result = chr(239) . chr(187) . chr(191) . $result;
15:27, 17 September 2013

I have the same problem with Excel 2013. Adding the line

$result = chr(239) . chr(187) . chr(191) . $result;

doesn't help. Has anyone an idea how to open the csv-file in Excel with the right character set?

15:11, 12 March 2015

Instead of hacking SMW core it will be more advisable to change settings in Excel. I thing this should do the trick: [1] (German only :( ). Supposedly newer versions should have similar settings, too. LibreOffice is much nicer in this respect since it politely asks upon import which charset to use.

There is also an new excel format. This may be an alternative too.


[1] http://www.rechtsmedizin.med.uni-muenchen.de/service/anleitungen_hilfe/excel_csv_utf8/index.html

17:13, 12 March 2015

I found a solution which works for me. I replaced the line:

$result = chr(239) . chr(187) . chr(191) . $result;

with:

$result = iconv("UTF-8", "CP1252", $result);
11:58, 17 March 2015
 
 
 
 
 

URL length in result link

When creating some query with format=csv and buch of properties (like 20+) resulting URL string becomes > 2000 cahracters. Current browsers handles it, but IE11 not, it cuts down string length to ~2000 characters. In result link becomes broken in IE11 (and IE9, possibly). Is there any workaround?

09:49, 23 October 2014

How do you specify tab as a separator?

Hi.

I would like to set a tab as the separator character. How do I specify this?

I tried sep=&#09, but that did not work.

Thanks!

15:28, 26 February 2013