Live data from Hacker News

Friends don't let friends export to CSV

kaveland.no

431–440 of 459 posts

Re: Friends don't let friends export to CSV

#431

Earlier quoted context omitted.

Sorry, this is not true _at all_ for geospatial data. A quick benchmark [0] shows that saving to GeoPackage, FlatGeobuf, and GeoParquet are roughly 10x faster than saving to CSV. Additionally, the CSV is much larger than any other format. [0]: https://gist.github.com/kylebarron/f632bbf95dbb81c571e4e64cd...

And here's my quick benchmark, dataset from my full-time job: > import geopandas as gpd > import pandas as pd > from shapely.geometry import Point > d = pd.read_csv('data/tracks/2024_01_01.csv') > d.shape (3690166, 4) > list(d) ['user_id', 'timestamp', 'lat', 'lon'] > %%timeit -n 1 > d.to_csv('/tmp/test.csv') 14.9 s ± 1.18 s per loop (mean ± std. dev. of 7 runs, 1 loop each) > d2 = gpd.GeoDataFrame(d.drop(['lon', 'la…

Your issue is that you're using the default (old) binding to GDAL, based on Fiona [0].

You need to use pyogrio [1], its vectorized counterpart, instead. Make sure you use `engine="pyogrio"` when calling `to_file` [2]. Fiona does a loop in Python, while pyogrio is exclusively compiled. So pyogrio is usually about 10-15x faster than fiona. Soon, in pyogrio version 0.8, it will be another ~2-4x faster than pyogrio is now [3].

[0]: https://github.com/Toblerity/Fiona

[1]: https://github.com/geopandas/pyogrio

[2]: https://geopandas.org/en/stable/docs/reference/api/geopandas...

[3]: https://github.com/geopandas/pyogrio/pull/346

Re: Friends don't let friends export to CSV

#432

Earlier quoted context omitted.

And here's my quick benchmark, dataset from my full-time job: > import geopandas as gpd > import pandas as pd > from shapely.geometry import Point > d = pd.read_csv('data/tracks/2024_01_01.csv') > d.shape (3690166, 4) > list(d) ['user_id', 'timestamp', 'lat', 'lon'] > %%timeit -n 1 > d.to_csv('/tmp/test.csv') 14.9 s ± 1.18 s per loop (mean ± std. dev. of 7 runs, 1 loop each) > d2 = gpd.GeoDataFrame(d.drop(['lon', 'la…

Your issue is that you're using the default (old) binding to GDAL, based on Fiona [0]. You need to use pyogrio [1], its vectorized counterpart, instead. Make sure you use `engine="pyogrio"` when calling `to_file` [2]. Fiona does a loop in Python, while pyogrio is exclusively compiled. So pyogrio is usually about 10-15x faster than fiona. Soon, in pyogrio version 0.8, it will be another ~2-4x faster than pyogrio is no…

Still CSV is 2x smaller than GPKG with this kind of data. And CSV.gz is 7x smaller.

Re: Friends don't let friends export to CSV

#433

Earlier quoted context omitted.

Your issue is that you're using the default (old) binding to GDAL, based on Fiona [0]. You need to use pyogrio [1], its vectorized counterpart, instead. Make sure you use `engine="pyogrio"` when calling `to_file` [2]. Fiona does a loop in Python, while pyogrio is exclusively compiled. So pyogrio is usually about 10-15x faster than fiona. Soon, in pyogrio version 0.8, it will be another ~2-4x faster than pyogrio is no…

Still CSV is 2x smaller than GPKG with this kind of data. And CSV.gz is 7x smaller.

That's why I'm working on the GeoParquet spec [0]! It gives you both compression-by-default and super fast reads and writes! So it's usually as small as gzipped CSV, if not smaller, while being faster to read and write than GeoPackage.

Try using `GeoDataFrame.to_parquet` and `GeoPandas.read_parquet`

[0]: https://github.com/opengeospatial/geoparquet

Re: Friends don't let friends export to CSV

#434
What's the best way to expose random CSV/.xlsx files for future joins etc? We're house hunting and it would be nice have a local db to keep track of price changes, asking prices, photos, etc. And look up (local) municipal OpenData for an address and grab the lot size, zoning, etc. I'm using Airtable and sometimes Excel, but it would be nice to have a home (hobby) setup for storing queryable data.

Re: Friends don't let friends export to CSV

#435
post #353
post #253

Earlier quoted context omitted.

Every now and then, yep :) https://mchap.io/that-time-the-city-of-seattle-accidentally-...

Wow, what a treasure trove you’ve got there! I’ve subscribed via RSS, in case anything else comes down the pipe :)

Thank you! Hopefully by the end of the year but these things can get, strange.

Re: Friends don't let friends export to CSV

#436
post #119

Earlier quoted context omitted.

> In the French locale, the decimal point is the comma, so "121.5" is written "121,5". It means, of course, that the comma can't be used as a separator Heh. Ah, HN. Always good for a laugh line.

Yeah, hon hon hon and all, but one of my (US) bank statements exports a CSV which uses commas in numbers in the US fashion, so $1,500 and the like. Writing a custom CSV munger to intake that into ledger-csv was... fun, but then again, only had to do it once.

That's exactly my point, and I still got downvoted.

This place...

Re: Friends don't let friends export to CSV

#437

Earlier quoted context omitted.

And here's my quick benchmark, dataset from my full-time job: > import geopandas as gpd > import pandas as pd > from shapely.geometry import Point > d = pd.read_csv('data/tracks/2024_01_01.csv') > d.shape (3690166, 4) > list(d) ['user_id', 'timestamp', 'lat', 'lon'] > %%timeit -n 1 > d.to_csv('/tmp/test.csv') 14.9 s ± 1.18 s per loop (mean ± std. dev. of 7 runs, 1 loop each) > d2 = gpd.GeoDataFrame(d.drop(['lon', 'la…

Your issue is that you're using the default (old) binding to GDAL, based on Fiona [0]. You need to use pyogrio [1], its vectorized counterpart, instead. Make sure you use `engine="pyogrio"` when calling `to_file` [2]. Fiona does a loop in Python, while pyogrio is exclusively compiled. So pyogrio is usually about 10-15x faster than fiona. Soon, in pyogrio version 0.8, it will be another ~2-4x faster than pyogrio is no…

CSV is still faster than geo-formats with pyogrio. From what I saw, it writes most of the file quickly, then spends a lot of time, I think, building the index.

        > %%timeit -n 1
        > d.to_csv('/tmp/test.csv')
        10.8 s ± 1.05 s per loop (mean ± std. dev. of 7 runs, 1 loop each)

        > %%timeit -n 1
        > d2.to_file('/tmp/test.gpkg', engine='pyogrio')
        1min 15s ± 5.96 s per loop (mean ± std. dev. of 7 runs, 1 loop each)

        > %%timeit -n 1
        > d.to_csv('/tmp/test.csv.gz')
        35.3 s ± 1.37 s per loop (mean ± std. dev. of 7 runs, 1 loop each)

        > %%timeit -n 1
        > d2.to_file('/tmp/test.fgb', driver='FlatGeobuf', engine='pyogrio')
        19.9 s ± 512 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

        > ls -lah /tmp/test*
        -rw-rw-r-- 1 culebron culebron 228M мар 27 11:02 /tmp/test.csv
        -rw-rw-r-- 1 culebron culebron  63M мар 27 11:27 /tmp/test.csv.gz
        -rw-rw-r-- 1 culebron culebron 545M мар 27 11:52 /tmp/test.fgb
        -rw-r--r-- 1 culebron culebron 423M мар 27 11:14 /tmp/test.gpkg

Re: Friends don't let friends export to CSV

#438

Earlier quoted context omitted.

On the other hand you can now use Power Query to import perquet data into Excel.

Whatever situation got you into the "Power" universe was bad. Warning you about M$, you will soon be an enterprise dev.

I am not in that universe, on the contrary I try to stay as far away as possible. And I agree with you. However I think the everything-done-in-OLD-Excel universe is worse. Some people will be terminally stuck in Excel but at least they can use new Excel capabilities instead of being stuck with the Excel of 20 years ago.

So why remain stuck importing CSVs into Excel when you can use Power Query to import Parquet. Why remain stuck using VBA in Excel when you can use Python in Excel.

I do not think an Excel user can be convinced to move to things like Jupyter, R, databases, etc. since they won't even make the jump to Access but maybe they can be convinced to use modern features of Excel.

Re: Friends don't let friends export to CSV

#439
post #409

Earlier quoted context omitted.

There's a difference between "1" and 1. When you import a csv and try to do maths on a "number" you won't get the expected result. Some importers won't even allow you to specify that "number" columns are numbers, they'll outright fail and force you to say it's a string, or you'll have to specify which columns are "numbers" and map the strings to numbers on the importer side. If they are numbers to begin with (not "nu…

Sounds to me like you're using a shitty parser. CSV is schemaless. It is up to you to tell the parser what types to use if it isn't unambiguous. Quoted values can be numbers, and unquoted values can be strings. I have not used any CSV tools that don't support this behaviour.

A shitty parser is one that assumes, if I quite a number I want it to be a string.

Re: Friends don't let friends export to CSV

#440

Earlier quoted context omitted.

And here's my quick benchmark, dataset from my full-time job: > import geopandas as gpd > import pandas as pd > from shapely.geometry import Point > d = pd.read_csv('data/tracks/2024_01_01.csv') > d.shape (3690166, 4) > list(d) ['user_id', 'timestamp', 'lat', 'lon'] > %%timeit -n 1 > d.to_csv('/tmp/test.csv') 14.9 s ± 1.18 s per loop (mean ± std. dev. of 7 runs, 1 loop each) > d2 = gpd.GeoDataFrame(d.drop(['lon', 'la…

Your issue is that you're using the default (old) binding to GDAL, based on Fiona [0]. You need to use pyogrio [1], its vectorized counterpart, instead. Make sure you use `engine="pyogrio"` when calling `to_file` [2]. Fiona does a loop in Python, while pyogrio is exclusively compiled. So pyogrio is usually about 10-15x faster than fiona. Soon, in pyogrio version 0.8, it will be another ~2-4x faster than pyogrio is no…

...but this has spared me today some irritation at work. Thanks!
Post reply on HN