Skip to main content
added 292 characters in body
Source Link
bxm
  • 5.2k
  • 1
  • 22
  • 26

You could use awk to process the data and save the different streams to different files.

Assuming the data is in a file called data:

awk '
  $1 ~ /^#INV/
     { gsub(/^#/,"", $1) ; out = $1".out" ; next }
  $1 !~ /^#/
     { print $0 >> out }
  ' data

This will result in files for each inverter being created in the current (if you'll forgive the pun) directory.

Works as follows..NB -- if you were to run this multiple times for the same data, you will need to remove/truncate the output files each time.

Works as follows...

Filter for lines which define an inverter section

$1 ~ /^#INV/

Remove leading #, define anthe output file, stop processing this line.

{ gsub(/^#/,"", $1) ; out = $1".out" ; next }

Filter for lines that do not start with #

$1 !~ /^#/

Append the current line to the active output file

{ print $0 >> out }

You could use awk to process the data and save the different streams to different files.

Assuming the data is in a file called data:

awk '
  $1 ~ /^#INV/
     { gsub(/^#/,"", $1) ; out = $1".out" ; next }
  $1 !~ /^#/
     { print $0 >> out }
  ' data

This will result in files for each inverter being created in the current (if you'll forgive the pun) directory.

Works as follows...

Filter for lines which define an inverter

$1 ~ /^#INV/

Remove leading #, define an output file, stop processing this line.

{ gsub(/^#/,"", $1) ; out = $1".out" ; next }

You could use awk to process the data and save the different streams to different files.

Assuming the data is in a file called data:

awk '
  $1 ~ /^#INV/
     { gsub(/^#/,"", $1) ; out = $1".out" ; next }
  $1 !~ /^#/
     { print $0 >> out }
  ' data

This will result in files for each inverter being created in the current (if you'll forgive the pun) directory.

NB -- if you were to run this multiple times for the same data, you will need to remove/truncate the output files each time.

Works as follows...

Filter for lines which define an inverter section

$1 ~ /^#INV/

Remove leading #, define the output file, stop processing this line.

{ gsub(/^#/,"", $1) ; out = $1".out" ; next }

Filter for lines that do not start with #

$1 !~ /^#/

Append the current line to the active output file

{ print $0 >> out }
Source Link
bxm
  • 5.2k
  • 1
  • 22
  • 26

You could use awk to process the data and save the different streams to different files.

Assuming the data is in a file called data:

awk '
  $1 ~ /^#INV/
     { gsub(/^#/,"", $1) ; out = $1".out" ; next }
  $1 !~ /^#/
     { print $0 >> out }
  ' data

This will result in files for each inverter being created in the current (if you'll forgive the pun) directory.

Works as follows...

Filter for lines which define an inverter

$1 ~ /^#INV/

Remove leading #, define an output file, stop processing this line.

{ gsub(/^#/,"", $1) ; out = $1".out" ; next }