kirtr · GitHub

From: https://hledger.org/1.29/hledger.html#skip
The word skip followed by a number (or no number, meaning 1) tells hledger to ignore this many non-empty lines at the start of the input data. (Empty/blank lines are skipped automatically, so you don't need to count those.) You'll need this whenever your CSV data contains header lines. Header lines skipped in this way are ignored, and not parsed as CSV.

This is a simplified Vanguard Roth IRA csv file. I get 3 lines that have to do with balances, then a csv header line and then my transactions. So I need to skip 4 lines, not including the blank ones.

My import file with a copy of the csv at the top.

#Investment,Balance
#Total Intl Stock,10
#Money Market,0
#
#
#
#Date,Type,Description,Symbol,Shares,Price,Amount
#2023-03-17,Dividend,Vanguard Total Intl Stock,VTIAX,0,1,132.94
#2023-03-17,Reinvestment,Vanguard Total Intl Stock,VTIAX,4.731,28.1,-132.94
skip 4
fields date, type, description, symbol, shares, price, amount
if Dividend
 skip
if Reinvestment
 description Vanguard | Roth Dividend - %shares shares at $%share_price each
 account1 Income:Retirement:Roth:Int
 amount1 %amount1 USD
 account2 Assets:Vanguard:Roth:Int
 amount2 %shares %symbol @@ %amount2 USD

Skip will only skip three lines, but not the fourth line. It insists on processing the second set of field names as data.

hledger import skip.csv
hledger: Error: error: could not parse "Date" as a date using date format "YYYY/M/D", "YYYY-M-D" or "YYYY.M.D"
CSV record: "Date","Type","Description","Symbol","Shares","Price","Amount"
the date rule is:   %1
the date-format is: unspecified
you may need to change your date rule, add a date-format rule, or change your skip rule
for m/d/y or d/m/y dates, use date-format %-m/%-d/%Y or date-format %-d/%-m/%Y

Read the original on github.com ↗