0
Fixed

CSV Download issues

mabene 7 years ago updated by James 7 years ago 7

I'm seeing a couple of issues with the downloaded .csv for tagged drives.

(Side note: I'm in Austria and I need to set my computers regional settings to English(USA) to be able to open the generated .csv file. Excel uses region specific field delimiters when opening .csv files. WTF.)
* Character set / encoding issues: I think .csv is supposed to use windows 1252 character set while the export you create seems to use UTF8(?) This means German Umlauts are broken on Import.
* Encoding of "&". this gets exported as "&" should be a literal "&" in .csv
* Column Wh/Kilometer is empty
* Column kWh Used is empty
* Drive Cost is empty

Some Things I would be grateful if they could be enhanced:

* Driving time is a text "x Hour y Minutes"; I'd much prefer a computer-friendly representation like "1:05"; perhaps in an additional column?
* Date / Start time End Time: the split date/time fields are not optimal for further processing, particularly if a drive should span midnight since there is no date information for the end time.

* would it be possible to also get the comment field and start/end GPS coordinates ?


Could You possible use "+" as a replacement for "&" for the moment? that would have a similar meaning and work regardless of language. Thanks a lot for your great support!

All done.

I've tried everything I can find on php with csv export and cannot find anything to resolve the & issue. There appears to be a lot of intricacies/issues with it.


I changed the string to replace "&" with "And" in the meantime until I can find something.

Fixed

I think I got it. It doesn't appear to be the charset. It need some special coding for excel - fprintf($output, chr(0xEF).chr(0xBB).chr(0xBF)); to be exact.


I also found the issue with exporting the day of signup.


Let me know if you run into any issues.


Thanks,


James

Sorry, only just got around to testing.


Your added code adds a BOM header to the .csv file to let excel know that the file is UTF-8 encoded. This works on current PC version of excel, but could fail on MAC versions of excel - I'm using a PC so I can't test if the issues mentioned here http://stackoverflow.com/questions/6588068/which-encoding-opens-csv-files-correctly-with-excel-on-both-mac-and-windows still apply. For my use case, the character encoding issue is fixed.


The 2nd issue, encoding of "&", is still open.


Thanks, Martin

Thanks for the quick reply. I can confirm that the empty columns are gone if the date range doesn't include start of recording.

the encoding issues are still there, download is still in utf8 format.

from download for 2017-03-12, expected vs Display in excel:

"Bäckerei Ringhofer GmbH" ==> Bäckerei Ringhofer GmbH

"Tesla Store & Service Graz" ==> Tesla Store & Service Graz

Also, thanks for splitting off the feature request.


Under review

Hi,


The empty columns appear to only happen when exporting the first day you signed up for teslafi on 3/6. If you export any other days it works as expected. There must be something in the code I need to skip over on the date of signup. I'll look into it.


I changed the encoding to windows-1252 if you want to see if that helps.


I created a feature request for you on the additions.


Thanks,


James



Commenting disabled