Sponsored Content
Full Discussion: Convert file in csv or table
Top Forums Shell Programming and Scripting Convert file in csv or table Post 302543083 by panyam on Friday 29th of July 2011 11:05:32 AM
Old 07-29-2011
Code:
 /objectname/ {f1=1;o=$2;next} --> if "objectname" present in a line store second field in variable "o" and set f1 flag

repeat the same login for other variables as well.

Once all the four values are available , print them and reset the flags f1,f2,f3,f4 to 0 again ( to avoid print other lines).
This User Gave Thanks to panyam For This Post:
 

10 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 the below file to csv format

Hi , i want to change this question, i will post soon.. (6 Replies)
Discussion started by: srikanth2567
6 Replies

3. Shell Programming and Scripting

Store table contents in csv file

I need to write a script to store the contents of a table in a csv file I'm using Toad, it's a Oracle database. (5 Replies)
Discussion started by: ladyAnne
5 Replies

4. UNIX for Dummies Questions & Answers

Storing data from a table into a csv file

Hi I need to write a bash script to take the data stored in 3 oracle tables .. and filter them and store the results in a csv file. It is an Oracle database Thank you (1 Reply)
Discussion started by: ladyAnne
1 Replies

5. Shell Programming and Scripting

Update the table using values from a csv file

i want to run update query for oracle which is in up.sql taking values from a.csv. I have implemented shell script to do it. extn="perl" ls -1 | while read file do echo "$file,$extn" > a.csv done up.sql contains update file_list set filename=$1 where extn=$2; The code to update is... (2 Replies)
Discussion started by: millan
2 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. Shell Programming and Scripting

Create a pivot table from CSV file

Gents, Can you please help me to create a pivot table from a csv file. ( I have zip the csv file) Using the file attached, columns 1,28 and 21 i would like to get something like this output JD Val 1 2 3 4 5 6 7 8 9 10 11 12 Total... (4 Replies)
Discussion started by: jiam912
4 Replies

8. 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

9. UNIX for Beginners Questions & Answers

1. This will insert the records into db table by reading from ta csv file

I have this code with me but the condition is If any of the mandatory columns are null then entire file will be rejected. LOAD DATA infile ' ' #specifies the name of a datafile containing data that you want to load BADFILE ' ' #specifies the name of... (1 Reply)
Discussion started by: raka123
1 Replies

10. Shell Programming and Scripting

Search in a file and convert in a table

Hi to all, I have a file like that in attach, I need to create a table or csv with only this field: "Barcode","Device Name", "ACSL". I tried with grep with -B options but the number of lines are different for any block is different, there is a method with sed or awk to extract it. Thanks a... (2 Replies)
Discussion started by: alen192
2 Replies
GIT-FOR-EACH-REF(1)						    Git Manual						       GIT-FOR-EACH-REF(1)

NAME
git-for-each-ref - Output information on each ref SYNOPSIS
git for-each-ref [--count=<count>] [--shell|--perl|--python|--tcl] [--sort=<key>]* [--format=<format>] [<pattern>...] DESCRIPTION
Iterate over all refs that match <pattern> and show them according to the given <format>, after sorting them according to the given set of <key>. If <count> is given, stop after showing that many refs. The interpolated values in <format> can optionally be quoted as string literals in the specified host language allowing their direct evaluation in that language. OPTIONS
<count> By default the command shows all refs that match <pattern>. This option makes it stop after showing that many refs. <key> A field name to sort on. Prefix - to sort in descending order of the value. When unspecified, refname is used. You may use the --sort=<key> option multiple times, in which case the last key becomes the primary key. <format> A string that interpolates %(fieldname) from the object pointed at by a ref being shown. If fieldname is prefixed with an asterisk (*) and the ref points at a tag object, the value for the field in the object tag refers is used. When unspecified, defaults to %(objectname) SPC %(objecttype) TAB %(refname). It also interpolates %% to %, and %xx where xx are hex digits interpolates to character with hex code xx; for example %00 interpolates to (NUL), %09 to (TAB) and %0a to (LF). <pattern>... If one or more patterns are given, only refs are shown that match against at least one pattern, either using fnmatch(3) or literally, in the latter case matching completely or from the beginning up to a slash. --shell, --perl, --python, --tcl If given, strings that substitute %(fieldname) placeholders are quoted as string literals suitable for the specified host language. This is meant to produce a scriptlet that can directly be `eval`ed. FIELD NAMES
Various values from structured fields in referenced objects can be used to interpolate into the resulting output, or as sort keys. For all objects, the following names can be used: refname The name of the ref (the part after $GIT_DIR/). For a non-ambiguous short name of the ref append :short. The option core.warnAmbiguousRefs is used to select the strict abbreviation mode. objecttype The type of the object (blob, tree, commit, tag). objectsize The size of the object (the same as git cat-file -s reports). objectname The object name (aka SHA-1). upstream The name of a local ref which can be considered `upstream'' from the displayed ref. Respects `:short in the same way as refname above. In addition to the above, for commit and tag objects, the header field names (tree, parent, object, type, and tag) can be used to specify the value in the header field. Fields that have name-email-date tuple as its value (author, committer, and tagger) can be suffixed with name, email, and date to extract the named component. The first line of the message in a commit and tag object is subject, the remaining lines are body. The whole message is contents. For sorting purposes, fields with numeric values sort in numeric order (objectsize, authordate, committerdate, taggerdate). All other fields are used to sort in their byte-value order. In any case, a field name that refers to a field inapplicable to the object referred by the ref does not cause an error. It returns an empty string instead. As a special case for the date-type fields, you may specify a format for the date by adding one of :default, :relative, :short, :local, :iso8601 or :rfc2822 to the end of the fieldname; e.g. %(taggerdate:relative). EXAMPLES
An example directly producing formatted text. Show the most recent 3 tagged commits:: .ft C #!/bin/sh git for-each-ref --count=3 --sort='-*authordate' --format='From: %(*authorname) %(*authoremail) Subject: %(*subject) Date: %(*authordate) Ref: %(*refname) %(*body) ' 'refs/tags' .ft A simple example showing the use of shell eval on the output, demonstrating the use of --shell. List the prefixes of all heads:: .ft C #!/bin/sh git for-each-ref --shell --format="ref=%(refname)" refs/heads | while read entry do eval "$entry" echo `dirname $ref` done .ft A bit more elaborate report on tags, demonstrating that the format may be an entire script:: .ft C #!/bin/sh fmt=' r=%(refname) t=%(*objecttype) T=${r#refs/tags/} o=%(*objectname) n=%(*authorname) e=%(*authoremail) s=%(*subject) d=%(*authordate) b=%(*body) kind=Tag if test "z$t" = z then # could be a lightweight tag t=%(objecttype) kind="Lightweight tag" o=%(objectname) n=%(authorname) e=%(authoremail) s=%(subject) d=%(authordate) b=%(body) fi echo "$kind $T points at a $t object $o" if test "z$t" = zcommit then echo "The commit was authored by $n $e at $d, and titled $s Its message reads as: " echo "$b" | sed -e "s/^/ /" echo fi ' eval=`git for-each-ref --shell --format="$fmt" --sort='*objecttype' --sort=-taggerdate refs/tags` eval "$eval" .ft Git 1.7.1 07/05/2010 GIT-FOR-EACH-REF(1)
All times are GMT -4. The time now is 06:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy