M
martin
Hi, I am quite new to perl and need to filter/process a file and print
into another file the processed file's results. I have .csv file that
is created by a perl script. The fomat of the file is
'M' lines or rows, and 'N' columns. the first row and the first column
are headers or labels.
all the fields are comma separated and are numeric values with the
excpetion of header and row columns shown below which are string
values, or labels.
Also the number of rows and columns could be as large as 1000 each.
I need to extract for a given column, example col4hdr, the
corresponding value for some of the rows and then print them in a
different file.
col1label, col2label, col3label, col4label, ..., colNlabel
row1hdr, int1, int2, ..., ... , intN-1
row2hdr, ... , ....,
.... ,... , ... , ... , ...., ...
rowMhdr ...., ..., ... , ..., ....
for example: if I were to extract and display the results for column4
and rows 2, 5, and 10, the output should like something like this
col1label col4label
row2hdr field value for 2,4
row5hdr field value for 5,4
row10hdr field value for 10,4
What is the most efficient way to do this, is there a built in
function in perl that does it,
how can I perl script this? should I turn the file into an array line
by line, or simply grep the file line by line for patterns maching
rows2hdr, row5hdr, row10hdr and then count 4 fileds till I extract the
corresponding value and store it for display.
and also is it best to use perl or unix shell scripting for this. any
input appreciated.
thanks. martin
into another file the processed file's results. I have .csv file that
is created by a perl script. The fomat of the file is
'M' lines or rows, and 'N' columns. the first row and the first column
are headers or labels.
all the fields are comma separated and are numeric values with the
excpetion of header and row columns shown below which are string
values, or labels.
Also the number of rows and columns could be as large as 1000 each.
I need to extract for a given column, example col4hdr, the
corresponding value for some of the rows and then print them in a
different file.
col1label, col2label, col3label, col4label, ..., colNlabel
row1hdr, int1, int2, ..., ... , intN-1
row2hdr, ... , ....,
.... ,... , ... , ... , ...., ...
rowMhdr ...., ..., ... , ..., ....
for example: if I were to extract and display the results for column4
and rows 2, 5, and 10, the output should like something like this
col1label col4label
row2hdr field value for 2,4
row5hdr field value for 5,4
row10hdr field value for 10,4
What is the most efficient way to do this, is there a built in
function in perl that does it,
how can I perl script this? should I turn the file into an array line
by line, or simply grep the file line by line for patterns maching
rows2hdr, row5hdr, row10hdr and then count 4 fileds till I extract the
corresponding value and store it for display.
and also is it best to use perl or unix shell scripting for this. any
input appreciated.
thanks. martin