I am trying to load a csv file with following date:
5
0 0
0 0.5
0 1
1 1
1 0
I am using following method:
df_data = CSV.read(filename; delim = ' ', header = false)
The issue is that it is not loading the second column.
I am trying to load a csv file with following date:
5
0 0
0 0.5
0 1
1 1
1 0
I am using following method:
df_data = CSV.read(filename; delim = ' ', header = false)
The issue is that it is not loading the second column.
In general, please quote your code.
Specifically, the issue here could be that the first row has a single cell. The quickest fix may be removing that row with a text editor, adding a cell if that makes sense, or using skipto
, ie
CSV.read(filename; delim = ' ', header = false, skipto = 2)
Thanks. The “skipto = 2” works fine. Indeed it is an issue due to single cell. If I put a space after single cell it works fine. But since this is the input file on which I have no control I will have to rely on skipto option.
I presume that the first line is the count of rows?
Keep in mind that CSV.read
automatically deduces the column types by default, so the command above will result in one int column and one float column, which might not be desired. You can use the types
argument if you know beforehand what the types are.