Sponsored Content
Top Forums Shell Programming and Scripting Search in a file and convert in a table Post 303037826 by rdrtx1 on Wednesday 14th of August 2019 10:02:33 AM
Old 08-14-2019
Code:
awk -v columns="Barcode,Device Name,ACSL" '
BEGIN {
  c=split(columns, headers, ",");
  for (i=1; i<=c; i++) labels[headers[i]]=headers[i];
}
{
 for (i=1; i<=NF; i++) {
    key=$i;
    sub("=.*", "", key);
    if (key in labels) {
       key=$i;
       sub("=.*", "", key);
       value=$i;
       sub(key "=", "", value);
       data[NR, key]=value;
    }
 }
}
END {
 print columns;
 for (i=1; i<=NR; i++) {
    line="";
    for (j=1; j<=c; j++) {
       line=line data[i, headers[j]] ",";
    }
    sub(",$", "", line);
    if (line ~ /..*,..*,..*/) print line;
 }
}
' FS="\n" RS="\n\n" file2.txt > file2.csv

# note: ex. excludes empty field lines
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Is it possible to convert text file to html table using perl

Hi, I have a text file say file1 having data like ABC c:/hm/new1 Dir DEF d:/ner/d sd ...... So i want to make a table from this text file, is it possible to do it using perl. Thanks in advance Sarbjit (1 Reply)
Discussion started by: sarbjit
1 Replies

2. Shell Programming and Scripting

Convert file in csv or table

Hi there, i have a file like that in attachment (PLEVA3_280711_SAP.txt), i would extract some basic information from it and report in a new file or table like this: i try to use bash and i extract the single object in this way (see attach scriptino.sh), but i receive a strange... (5 Replies)
Discussion started by: alen192
5 Replies

3. Shell Programming and Scripting

Convert shell script output txt file to html table

Hi, I have script which generates the output as below: Jobname Date Time Status abc 12/9/11 17:00 Completed xyz 13/9/11 21:00 Running I have the output as a text file. I need to convert it into a HTML Table and sent it thru email ... (6 Replies)
Discussion started by: a12ka4
6 Replies

4. Shell Programming and Scripting

convert to uppercase in specific table

Hi All, I'm a newbie here, i'm just wondering is it possible to convert into uppercase the records in specific field? ex. table name = mytable field1 field2 field3 abd erfdF fdsfdsfsd how can i convert into uppercase the field2 using sybase? Please advise, ... (2 Replies)
Discussion started by: nikki1200
2 Replies

5. Shell Programming and Scripting

convert the output in table format

Hi All, I have a output like below values val1=test.com val2=10.26.208.11 val3=en1 val4=test-priv1.com val5=192.168.3.4 val6=en2 val7=test-priv2.com val8=192.168.4.4 val9=en3 val10=test-vip.com val11=10.26.208.9 val12=$val3 I want to convet this output values into below... (1 Reply)
Discussion started by: kamauv234
1 Replies

6. Shell Programming and Scripting

awk to convert table-by-row to matrix table

Hello, I need some help to reformat this table-by-row to matrix? infile: site1 A:o,p,q,r,s,t site1 C:y,u site1 T:v,w site1 -:x,z site2 A:p,r,t,v,w,z site2 C:u,y site2 G:q,s site2 -:o,x site3 A:o,q,s,t,u,z site3 C:y site3 T:v,w,x site3 -:p,routfile: SITE o p q r s t v u w x y... (7 Replies)
Discussion started by: yifangt
7 Replies

7. UNIX for Dummies Questions & Answers

Convert Txt file to HTML table and email

Hi all I need help converting a text file into a html table in bash and I need to email this table. The text file looks like the below. Two columns with multiple rows. Top row being header. Application Name Application Status Application 1 Open Application 2 ... (2 Replies)
Discussion started by: hitmanjd
2 Replies

8. Shell Programming and Scripting

Convert shell script output txt file to html table

My concnern related to the post -Convert shell script output txt file to html table, in this how to print the heading as color. awk 'BEGIN{print "<table>"} {print "<tr>";for(i=1;i<=NF;i++)print "<td>" $i"</td>";print "</tr>"} END{print "</table>"}' <filename> (8 Replies)
Discussion started by: sarajobmai
8 Replies
set_ucodepage(3alleg4)						  Allegro manual					    set_ucodepage(3alleg4)

NAME
set_ucodepage - Sets 8-bit to Unicode conversion tables. Allegro game programming library. SYNOPSIS
#include <allegro.h> void set_ucodepage(const unsigned short *table, const unsigned short *extras); DESCRIPTION
When you select the U_ASCII_CP encoding mode, a set of tables are used to convert between 8-bit characters and their Unicode equivalents. You can use this function to specify a custom set of mapping tables, which allows you to support different 8-bit codepages. The `table' parameter points to an array of 256 shorts, which contain the Unicode value for each character in your codepage. The `extras' parameter, if not NULL, points to a list of mapping pairs, which will be used when reducing Unicode data to your codepage. Each pair con- sists of a Unicode value, followed by the way it should be represented in your codepage. The list is terminated by a zero Unicode value. This allows you to create a many->one mapping, where many different Unicode characters can be represented by a single codepage value (eg. for reducing accented vowels to 7-bit ASCII). Allegro will use the `table' parameter when it needs to convert an ASCII string to an Unicode string. But when Allegro converts an Unicode string to ASCII, it will use both parameters. First, it will loop through the `table' parameter looking for an index position pointing at the Unicode value it is trying to convert (ie. the `table' parameter is also used for reverse matching). If that fails, the `extras' list is used. If that fails too, Allegro will put the character `^', giving up the conversion. Note that Allegro comes with a default `table' and `extras' parameters set internally. The default `table' will convert 8-bit characters to `^'. The default `extras' list reduces Latin-1 and Extended-A characters to 7 bits in a sensible way (eg. an accented vowel will be reduced to the same vowel without the accent). SEE ALSO
set_uformat(3alleg4) Allegro version 4.4.2 set_ucodepage(3alleg4)
All times are GMT -4. The time now is 09:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy