Comments (3)
import pygef
pygef.read_cpt("./KNM_GEF_stuk/S0270_35.gef")
> Traceback (most recent call last):
> File "/home/robin/Documents/Repositories/pygef/venv/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3460, in run_code
> exec(code_obj, self.user_global_ns, self.user_ns)
> File "<ipython-input-3-4d7bdd2c1549>", line 3, in <module>
> pygef.read_cpt("./KNM_GEF_stuk/S0270_35.gef")
> File "/home/robin/Documents/Repositories/pygef/venv/lib/python3.9/site-packages/pygef/shim.py", line 82, in read_cpt
> return gef_cpt_to_cpt_data(_GefCpt(path=file))
> File "/home/robin/Documents/Repositories/pygef/venv/lib/python3.9/site-packages/pygef/gef/parse_cpt.py", line 134, in __init__
> self.parse_data(
> File "/home/robin/Documents/Repositories/pygef/venv/lib/python3.9/site-packages/pygef/gef/gef.py", line 151, in parse_data
> return pl.read_csv(
> File "/home/robin/Documents/Repositories/pygef/venv/lib/python3.9/site-packages/polars/io/csv/functions.py", line 354, in read_csv
> df = pl.DataFrame._read_csv(
> File "/home/robin/Documents/Repositories/pygef/venv/lib/python3.9/site-packages/polars/dataframe/frame.py", line 784, in _read_csv
> self._df = PyDataFrame.read_csv(
> exceptions.ComputeError: projection index 1 is out of bounds for CSV schema with 1 columns
The #COLUMNSEPARATOR
argument is not set in the GEF file. Therefore pyGEF
assumes a space is used. Base on the GEF file a tab is used as separator.
import pygef
# Read in the file
with open('./KNM_GEF_stuk/S0270_35.gef', 'r') as file :
filedata = file.read()
# Replace the target string
filedata = filedata.replace('\t', ' ')
# Write the file out again
with open('./KNM_GEF_stuk/S0270_35.gef', 'w') as file:
file.write(filedata)
pygef.read_cpt("./KNM_GEF_stuk/S0270_35.gef")
Its nicer to provide a parsing error and not a polars error.
from pygef.
Yes, throwing a custom error would definitely be preferred, e.g. pygef.exceptions.ParseCptGefError
We could throw it if the inferred column-separator can not be found on every row in the CSV-data for the expected amount of times (= #columns - 1).
from pygef.
Linked to #367
from pygef.
Related Issues (20)
- Import from gpkg HOT 1
- Issue with plotting with Robertson classification HOT 1
- GEF with single line data, can't be read HOT 5
- Add CPTData documentation HOT 1
- read_cpt should return dedicated exception if file is not gef or xml HOT 1
- update soil distribution
- matplotlib internal errors
- polars internal errors
- sort dataframe
- plot inverted
- Missing dependency 'typing_extensions' HOT 3
- import as file error (xml, CPT, Bore) HOT 3
- missing dependency typing_extensions
- exceptions.ComputeError: arithmetic on string and numeric not allowed, try an explicit cast first HOT 1
- read functions should return insightful errors HOT 3
- read functions should throw error for unknown engine
- parsing error HOT 1
- Cannot parse GEF file HOT 1
- gef parsing failes due to tab delimiter
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pygef.