Julia CSV skipping rows

Viewed 838

I have a csv file as shown below. I basically want to add the last two rows into a dataframe (24 & 25). Unfortunately with the program (Netlogo), generating this file it's not possible to export this as a xlsx file. So using the package xlsx gives me an error. I am wondering how to skiprows and get a dataframe. I'vs tried this piece of code but it gives me 2x1 DataFrame with X and 0 as values(Basically column A and rows 24-25). What I am after is rows 24-25 and columns A to AC

 using DataFrames
 using CSV

 df = CSV.File(
    joinpath("D:/ABM/Simulation Runs/Output Files/run_1.csv"),
    skipto = 24
)

enter image description here

1 Answers

You can use (you could do the same with CSV.File if you do not want DataFrame as a sink):

CSV.read("run_1.csv DataFrame, header=24, limit=1, threaded=false)

Explanation:

  • header: line in which header is stored
  • limit: number of rows of data to read (omit it if below header you only have data),
  • threaded: use this to ensure that limit is respected exactly (as in general CSV.jl might use multiple threads to read your data and try to read more than asked)
Related