-
Notifications
You must be signed in to change notification settings - Fork 644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No column detected from CSV with no data (header row only) #815
Comments
I guess this would be a bug, but a fairly minor one from my perspective. I don't see the use-case for reading a file with nothing but a header line. Tablesaw is geared more towards analyzing existing datasets than on building datasets in memory. Of course you can create a table entirely in code, but I've only ever used that for testing. Have you found any work arounds? I think i would look at either (a) trying to load the file with the column types pre-specified (I notice all your columns are strings), or (b), just reading the headers using a standard java file reading approach and creating the table in code, by looping over the names |
Hi, The code snippet is here just to reproduce the bug. The real code scan pragmatically a folder for new CSV files and apply some business logic (we compute new columns based on existing columns) on some criteria. For now, when we read the table, if the table is empty we copy the file as-is. |
Is there an option now for keeping all columns when reading a header-only file (even when the column types can't be determined of course)? In our use case, we write many tables automated in batch, and some of them could potentially end up being empty. Nevertheless, we have the same column headers across files. Currently, we get an exception (in MoBIE which depends on tablesaw) because tablesaw returns a /cc @tischi |
Columns have to have a type. Maybe if you’re using the same columns
repeatedly, you could include one row of dummy data and then delete it?
If that’s impossible, you could read the column names and build the table
in code, perhaps making them all string columns. They would then need to
be converted to the proper types manually.
…On Wed, Mar 29, 2023 at 4:05 AM Jan Eglinger ***@***.***> wrote:
Is there an option now for keeping all columns when reading a header-only
file (even when the column *types* can't be determined of course)?
In our use case, we write many tables automated in batch, and some of them
could potentially end up being empty. Nevertheless, we have the same column
headers across files. Currently, we get an exception (in MoBIE which
depends on tablesaw) because tablesaw returns a Table without columns at
all. I would have expected at least all the columnNames() be the same as
in the (header-only) input file.
—
Reply to this email directly, view it on GitHub
<#815 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA2FPAUWTJOFIZ7WZ7P5QOTW6PUNXANCNFSM4ORMO2RA>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
Hi,
I read a CSV file with no data (header row only) and I noticed that no column was detected.
The resulting table is empty.
Did I make something wrong?
Any help would be greatly appreciated.
The text was updated successfully, but these errors were encountered: