Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Data extraction and converting into .csv file. Post 303013913 by RudiC on Friday 2nd of March 2018 01:03:56 AM
Old 03-02-2018
No attempts / ideas / thoughts from your side?


try
Code:
awk '/----\r$/ && $1=$1' OFS=, /tmp/sample_linebyline.txt 
840-1,1,ABCD,0010211-00,0012345678/012345678912,123456789012,2745.25-,----
840-1,1,ABCD,0010211-00,0012345678/012345678912,123456789012,2745.25,----

taking into account that your file has non-*nix but DOS line teminators.

EDIT: And for your other file, which has several trailing spaces in the lines, try
Code:
awk '/---- *\r$/ && $1=$1' OFS=, /tmp/flatfile_sample.txt 
840-1,1,ABCD,0010211-00,0012345678/012345678912,123456789012,2745.25-,----,
840-1,1,ABCD,0010211-00,0012345678/012345678912,123456789012,2745.25,----,


Last edited by RudiC; 03-02-2018 at 02:10 AM..
This User Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Data Extraction From a File

Hi All, I have a requirement where I have to search the file with some text say "Exception". This exception word can be repeated for more then 10 times. Suppose the "Exception" word is repeated at line numbers say x=10, 50, 60, 120. Now I want to extract all the lines starting from x-5 to... (3 Replies)
Discussion started by: rrangaraju
3 Replies

2. Shell Programming and Scripting

Converting txt file in csv

HI All, I have a text file memory.txt which has following values. Average: 822387 7346605 89.93 288845 4176593 2044589 51883 2.47 7600 i want to convert this file in csv format and i am using following command to do it. sed s/_/\./g <... (3 Replies)
Discussion started by: mkashif
3 Replies

3. Shell Programming and Scripting

Converting variable space width data into CSV data in bash

Hi All, I was wondering how I can convert each line in an input file where fields are separated by variable width spaces into a CSV file. Below is the scenario what I am looking for. My Input data in inputfile.txt 19 15657 15685 Sr2dReader 107.88 105.51... (4 Replies)
Discussion started by: vharsha
4 Replies

4. Shell Programming and Scripting

data extraction from a file

Hi Freinds, I have a file1.txt in the following format File1.txt I want to get 2 files from the above file filextra.txt should have the lines which are ending with "<" and remaining lines in the filecompare.txt file. Please help. (3 Replies)
Discussion started by: i150371485
3 Replies

5. Shell Programming and Scripting

FILE_ID extraction from file name and save it in CSV file after looping through each folders

FILE_ID extraction from file name and save it in CSV file after looping through each folders My files are located in UNIX Server, i want to extract file_id and file_name from each file .and save it in a CSV file. How do I do that? I have folders in unix environment, directory structure is... (15 Replies)
Discussion started by: princetd001
15 Replies

6. Shell Programming and Scripting

Data extraction from .txt file

Hey all, i´ve got the following problem: i´m aquiring data with an instrument and i get data in a .txt file. This is how the txt file looks like: Report of AU program poptau F1P=-49.986ppm F2P=-110.014ppm Target directory for serfile: D:/data/Spect500/nmr/Thoma/882 Linear... (17 Replies)
Discussion started by: expikx
17 Replies

7. Shell Programming and Scripting

Converting data for text file to csv

Gents Using the script attached (raw2csv). i use to create the file .csv.. The input file is called 201.raw. Kindly can you check if there is easy way to do it. The script works fine but takes a lot time to process Thanks for your help (8 Replies)
Discussion started by: jiam912
8 Replies

8. Shell Programming and Scripting

CSV file data extraction

Hi I am writing a shell script to parse a CSV file , in which i am facing a problem to separate the columns . Could some one help me with it. IN301330/00001 pvavan kumar limited xyz@ttccpp.com IN302148/00002 PRECIOUS SECURITIES (P) LTD viash@yahoo.co.in IN300239/00000 CENTRE india... (8 Replies)
Discussion started by: nanduri
8 Replies

9. Shell Programming and Scripting

Compare 2 files of csv file and match column data and create a new csv file of them

Hi, I am newbie in shell script. I need your help to solve my problem. Firstly, I have 2 files of csv and i want to compare of the contents then the output will be written in a new csv file. File1: SourceFile,DateTimeOriginal /home/intannf/foto/IMG_0713.JPG,2015:02:17 11:14:07... (8 Replies)
Discussion started by: refrain
8 Replies

10. Shell Programming and Scripting

Data extraction from .xml file

Hello, I'm attempting to extract 13 digit numbers beginning with 978 from a data file with the following command: awk '{ for(i=1;i<=NF;i++) if($i ~ /^978/) print $i; }' datafile > outfile This typically works. However, the new data file is an .xml file, and this command is no longer working... (6 Replies)
Discussion started by: palex
6 Replies
Barcode(3)						User Contributed Perl Documentation						Barcode(3)

NAME
GD::Barcode - Create barcode image with GD SYNOPSIS
ex. CGI use GD::Barcode::UPCE; binmode(STDOUT); print "Content-Type: image/png "; print GD::Barcode->new('EAN13', '123456789012')->plot->png; with Error Check my $oGdBar = GD::Barcode->new('EAN13', '12345678901'); die $GD::Barcode::errStr unless($oGdBar); #Invalid Length $oGdBar->plot->png; DESCRIPTION
GD::Barcode is a subclass of GD and allows you to create barcode image with GD. This module based on "Generate Barcode Ver 1.02 By Shisei Hanai 97/08/22". From 1.14, you can use this module even if no GD (except plot method). new $oGdBar = GD::Barcode::UPCE->new($sType, $sTxt); Constructor. Creates a GD::Barcode::$sType object for $sTxt. plot() $oGd = $oGdBar->plot([Height => $iHeight, NoText => 0 | 1]); creates GD object with barcode image for the $sTxt specified at new method. $iHeight is height of the image. If NoText is 1, the image has no text image of $sTxt. ex. my $oGdB = GD::Barcode->new('EAN13', '123456789012'); my $oGD = $oGdB->plot(NoText=>1, Height => 20); # $sGD is a GD image with Height=>20 pixels, with no text. barcode() $sPtn = $oGdBar->barcode(); returns a barcode pattern in string with '1' and '0'. '1' means black, '0' means white. ex. my $oGdB = GD::Barcode->new('UPCE', '123456789012'); my $sPtn = $oGdB->barcode(); # $sPtn = ''; $errStr $GD::Barcode::errStr has error message. $text $oGdBar->{$text} has barcode text based on $sTxt specified in new method. AUTHOR
Kawai Takanori GCD00051@nifty.ne.jp COPYRIGHT
The GD::Barocde module is Copyright (c) 2000 Kawai Takanori. Japan. All rights reserved. You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file. SEE ALSO
GD GD::Barcode subclasses perl v5.16.3 2004-04-24 Barcode(3)
All times are GMT -4. The time now is 02:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy