Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transforming column data to row data for spreadsheet importing

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have parsed text data from HP GlancePlus into columnar data: 13 repeating parameters, each followed by a blank line. I have about 500KB to alter. I want eventually, to import the 13 columns of data into a spreadsheet. Data looks like:
20
4
92
34
0.0
220.3
88.7
491.7
1024
47.7
358.4
85.2
11/05/01 13:27:40
(blank line)
(repeat similar data).

It must look like:
12 4 92 34 0.0 220.3 88.7 491.7 1024 47.7 358.4 85.2 11/05/01 13:27:40
(next row).

I'm not skilled with AWK, but would like to use AWK to do this, and would appreciate any pointers.
bobh41

 
I don't know where the 12 at the beginning of the line comes from but if it is supposed to be 20 then the following program will do it.
Code:
{
  if ($0 == "")
    print ""
  else
   printf $0 " "
}
Hope this helps. CaKiwi
 
If on the other hand the first value should always be 12 then this may be what you want.
Code:
{
  if ($0 == "") {
    print ""
    flg = 0
  }
  else if (!flg) {
    printf "12 "
    flg = 1
  }
  else
   printf $0 " "
}
Hope this helps. CaKiwi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top