shell - add column with incrementing integer to multiple csv files -


I have thousands of CSV files, each has 64 columns and 700+ lines I combine to import into database tables Want to

Using a cat, there is no problem combining the files. However, each file represents a different event, so when I ask the database, I would like to be able to extract just the lines from the personal file.

For example:

log_phile1

  • For example:

  • A, B, C, D, ...

    log_phil

  • A, B, C, D, ...
  • A, B, C, D, ...
  • A, B, 1, A, A, B, C, B, C, D ...
  • 1, A, B, C,
  • B, C, D ...
  • 2, A, B, C, D ...

    thanks

    With awk, you can write:

      awk 'FNR == 1 {count ++} {print count "," $ 0}' * .csv   

    This increases the "count" variable when the first record is being processed by each file.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -