Can a CSV file have a comment?

前端 未结 7 1348
悲&欢浪女
悲&欢浪女 2020-12-02 16:29

Is there any official way to allow a CSV formatted file to allow comments, either on its own line OR at the end of a line?

I tried checking wikipedia on this and als

相关标签:
7条回答
  • 2020-12-02 17:00

    If you're parsing the file with a FOR command in a batch file a semicolon works (;)

    REM test.bat contents
    
    for /F "tokens=1-3 delims=," %%a in (test.csv) do @Echo %%a, %%b, %%c
    

    ;test.csv contents (this line is a comment)
    
    ;1,ignore this line,no it shouldn't
    
    2,parse this line,yes it should!
    
    ;3,ignore this line,no it shouldn't
    
    4,parse this line,yes it should!
    

    OUTPUT:

    2, parse this line, yes it should!
    
    4, parse this line, yes it should!
    
    0 讨论(0)
提交回复
热议问题