Closed ddrury closed 4 years ago
The problem with trim()
is that it removes too much.
CSV files use a double-enclosure character to embed it in text.
So, if we are using "
as an enclosure, then we encode "
as ""
. e.g.
php > fputcsv(fopen('php://output', 'w'), ['foo', '"bar"', 'baz'], ';', '"');
foo;"""bar""";baz
We really need to use fputcsv()
and fgetcsv()
.
FYI, here's a placename in one of my test files: "Minnehaha", on the steamship
.
I have updated the 1.7 code to use fputcsv()
and fgetcsv()
.
In my tests, it can read files generated by 2.0 and also earlier versions of 1.7.
(And also files created by MS Excel.)
Can you test for me?
I have a problem with a file I've just exported from 1.7 prior to this update
The header line is
"Level";"Country";"State";"County";"City";"Longitude";"Latitude";"Zoom level";"Icon";
note the trailing semicolon, this causes an error in line 3787 $fields is calculated as 10 not 9
Dang. I guess we need to ignore the header row, and count columns in the data rows.
Fix incoming...
Latest commit fixes it - Minihaha is still afloat
Thanks for testing.
There's something wrong with my system that prevents me creating a pull request for this! In the googlemaps module add the following code at about line 3799. I'm sure that there is a more correct way to do this with the existing code but said code makes my brain hurt.
Existing code
Insert new code
Existing code