Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How can I stack multiple (>1000) fields into one continuous field? Post 303034942 by Corona688 on Thursday 9th of May 2019 03:59:47 PM
Old 05-09-2019
If your input is tab-separated:
Code:
awk -F"\t" '{ if(NF>M) M=NF; for(N=1; N<=NF; N++) if($N) D[N,++C[N]]=$N } END { for(N=1; N<=M; N++) for(X=1; X<=C[N]; X++) print D[N,X] }' inputfile > outputfile

These 4 Users Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to split a field into two fields?

Hi, I have a comma delimited text file where character fields (as opposed to numeric and date fields) are always enclosed with double quotes. Records are separated by the newline character. In a shell script I would like to split a particular field into two separate fields (enclosed with double... (4 Replies)
Discussion started by: vbrown
4 Replies

2. Shell Programming and Scripting

Sorting on two fields time field and number field

Hi, I have a file that has data in it that says 00:01:48.233 1212 00:01:56.233 345 00:09:01.221 5678 00:12:23.321 93444 The file has more line than this but i just wanted to put in a snippet to ask how I would get the highest number with time stamp into another file. So from the above... (2 Replies)
Discussion started by: pat4519
2 Replies

3. UNIX for Dummies Questions & Answers

Formatting Multiple fields on 1 line to multiple rows

I'm trying extract a number of filename fields from a log file and copy them out as separate rows in a text file so i can load them into a table. I'm able to get the filenames but the all appear on one line. I tried using the cut command with the -d (delimiter) option but cant seem to make it... (1 Reply)
Discussion started by: Sinbad-66
1 Replies

4. Shell Programming and Scripting

compare two fields and get a third field

Hello, I'm trying to get a value based on a comparison of two fields, this is: file1 687.45 687.18 687.322 687.405 686.865 file 2 685 6.43 686 6.43 687 6.42 688 6.42 (3 Replies)
Discussion started by: Gery
3 Replies

5. Shell Programming and Scripting

How to print 1st field and last 2 fields together and the rest of the fields after it using awk?

Hi experts, I need to print the first field first then last two fields should come next and then i need to print rest of the fields. Input : a1,abc,jsd,fhf,fkk,b1,b2 a2,acb,dfg,ghj,b3,c4 a3,djf,wdjg,fkg,dff,ggk,d4,d5 Expected output: a1,b1,b2,abc,jsd,fhf,fkk... (6 Replies)
Discussion started by: 100bees
6 Replies

6. Shell Programming and Scripting

UNIX append field with comparing fields from multiple column

I have a csv dump from sql server that needs to be converted so it can be feed to another program. I already sorted on field 1 but there are multiple columns with same field 1 where it needs to be compared against and if it is same then append field 5. i.e from ANG SJ,0,B,LC22,LC22(0) BAT... (2 Replies)
Discussion started by: nike27
2 Replies

7. Linux

How do I format a Date field of a .CSV file with multiple commas in a string field?

I have a .CSV file (file.csv) whose data are all enclosed in double quotes. Sample format of the file is as below: column1,column2,column3,column4,column5,column6, column7, Column8, Column9, Column10 "12","B000QRIGJ4","4432","string with quotes, and with a comma, and colon: in... (3 Replies)
Discussion started by: dhruuv369
3 Replies

8. Shell Programming and Scripting

Single Field to multiple fields searching

I have a fileA with one column (1000 rows), and fileB with 26 columns(13000 rows). I need to search each value of fileA with fileB and return all the 26 values from FileB to a new file- File C if matches. The search value (from FileA) may present in any of the 26 values in FileB. This value is not... (7 Replies)
Discussion started by: vamsikrishna928
7 Replies

9. Shell Programming and Scripting

Inserting a field without disturbing field separator on other fields

Hi All, I have the input as below: cat input 032016002 2.891 97.109 16.605 27.172 24.017 32.207 0.233 0.021 39.810 0.077 0.026 19.644 13.882 0.131 11.646 0.102 11.449 76.265 23.735 16.991 83.009 8.840 91.160 0.020 99.980 52.102 47.898 44.004 55.996 39.963 18.625 0.121 1.126 40.189... (15 Replies)
Discussion started by: am24
15 Replies

10. UNIX for Beginners Questions & Answers

Extract a column and multiple by 1000 and replace it on same file

Hi All, I need to extract a position in the file and multiple the value by 1000 and the replace it . Original 0010001200084701217637306521200000000000010010000000 ---> 000847 * 1000 0010012700086001213437404323000000000000001001000000 ---> 000860 * 1000... (2 Replies)
Discussion started by: arunkumar_mca
2 Replies
PX_INSERT_RECORD(3)													       PX_INSERT_RECORD(3)

px_insert_record - Inserts record into paradox database

SYNOPSIS
int px_insert_record (resource $pxdoc, array $data) DESCRIPTION
Inserts a new record into the database. The record is not necessarily inserted at the end of the database, but may be inserted at any position depending on where the first free slot is found. The record data is passed as an array of field values. The elements in the array must correspond to the fields in the database. If the array has less elements than fields in the database, the remaining fields will be set to null. Most field values can be passed as its equivalent php type e.g. a long value is used for fields of type PX_FIELD_LONG, PX_FIELD_SHORT and PX_FIELD_AUTOINC, a double values is used for fields of type PX_FIELD_CURRENCY and PX_FIELD_NUMBER. Field values for blob and alpha fields are passed as strings. Fields of type PX_FIELD_TIME and PX_FIELD_DATE both require a long value. In the first case this is the number of milliseconds since mid- night. In the second case this is the number of days since 1.1.0000. Below there are two examples to convert the current date or timestamp into a value suitable for one of paradox's date/time fields. Note This function is only available if pxlib >= 0.6.0 is used. PARAMETERS
o $pxdoc - Resource identifier of the paradox database as returned by px_new(3). o $data - Associated or indexed array containing the field values as e.g. returned by px_retrieve_record(3). RETURN VALUES
Returns FALSE on failure or the record number in case of success. EXAMPLES
Example #1 Set the date/time fields in a paradox database to the current date/time <?php $px = px_new(); $fp = fopen("test.db", "w+"); px_create_fp($px, $fp, array(array("timestamp", "@"), array("time", "T"), array("date", "D"))); $curdate = getdate(); $jd = gregoriantojd($curdate["mon"], $curdate["mday"], $curdate["year"]); $days = $jd - 1721425; /* Number of days between 1.1.4714 b.c. and 1.1.0000 */ $secs = $curdate["hours"]*3600 + $curdate["minutes"]*60 + $curdate["seconds"]; px_insert_record($px, array($days*86400000.0 + $secs*1000.0, $secs*1000.0, $days)); $curtimestamp = microtime(true); $days = (int) ($curtimestamp/86400); $secs = $curtimestamp - ($days * 86400.0); $days += 2440588; /* Number of days between 1.1.4714 b.c. and 1.1.1970 */ $days -= 1721425; /* Number of days between 1.1.4714 b.c. and 1.1.0000 */ px_insert_record($px, array($days*86400000.0 + $secs*1000.0, $secs*1000.0, $days)); for($i=0; $i<2; $i++) { $rec = px_retrieve_record($px, $i); echo px_timestamp2string($px, $rec["timestamp"], "n/d/Y H:i:s")." "; echo px_date2string($px, $rec["date"], "n/d/Y")." "; } px_close($px); px_delete($px); ?> The above example will output: 2/21/2006 21:42:30 2/21/2006 2/21/2006 20:42:30 2/21/2006 The Julian day count as passed to jdtogregorian(3) has a different base of 1.1.4714 b.c. and must therefore be calculated by adding 1721425 to the day count used in the paradox file. Turning the day count into a timestamp is easily done by multiplying with 86400000.0 to obtain milli seconds. SEE ALSO
px_update_record(3) PHP Documentation Group PX_INSERT_RECORD(3)
All times are GMT -4. The time now is 08:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy