How to extract data from CSV files?

How to extract data from CSV files?

Fing for Console may output the content of the discovery in a classical Comma-Separated-Output, which actually uses a semicolon to separate the content. You may generate the CSV output using the appropriate output format, as in the example below:

 <cmd> -r1 -n10.255.0.0/16 -o table,csv,fingscan.csv

The file contains the discovery data is in the following order:

  1. IP address
  2. Custom Name of the Node (if you have assigned custom names in the .properties file)
  3. The state (UP/DOWN)
  4. The timestamp of last change
  5. The host name (if you have enabled DNS)
  6. The Hardware address (if you are discoverying a local network)
  7. The Hardware vendor

You may eliminate one of the column with simple scripts. On Unix and Mac Os X, you may use an “awk oneliners”, like:

 awk -F ";" '{print $1, $2, $3, $5, $6, $7}' yourfile.csv

On Windows, you may use the PowerShell, like:

 Get-Content yourfile.csv | %{ $_.Split(';')[1]; }

which extracts the first column. There is also the import-csv cmdlet which provides many features.

Was this article helpful?