Sponsored Content
Top Forums Shell Programming and Scripting need to save the space when converting to CSV file Post 302603935 by wintersnow2011 on Friday 2nd of March 2012 10:34:44 AM
Old 03-02-2012
need to save the space when converting to CSV file

Hi,

I have a text file with the following format. Some of the fields are blank.

Code:
1234    3456    23  45464  327837283232    343434
      5654353    34  34343    3434345          434242

....

....

....


I need to convert this file to a CSV file, like
Code:
1234,    ,23,  ,454,64,3278,3728,3232,    ,343,434

Here is my code:

Code:
inputFile="test"
outputFile="test.csv"
 
while read line
do
    f1=`echo $line | cut -c1-4`
    f2=`echo $line | cut -c5-8`
    f3..
    f4..
    .. 
    ..
    echo "$f1,$f2,$f3....." >> $outputFile
done < $inputFile

but in the outputFile, all the blank are erased. Can anyone help me out here?

Thanks!!Smilie

Last edited by joeyg; 03-02-2012 at 11:41 AM.. Reason: Please wrap sample data and scripts with CodeTags
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Data fetched from text file and save in a csv file

Hi i have wriiten a script which fetches the data from text file, and saves in the output in a text file itself, but i want that the output should save in different columns. I have the output like: For Channel:response_time__24.txt 1547 data points 0.339 0.299 0.448 0.581 7.380 ... (1 Reply)
Discussion started by: rohitkalia
1 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. UNIX for Dummies Questions & Answers

CSV file:Find duplicates, save original and duplicate records in a new file

Hi Unix gurus, Maybe it is too much to ask for but please take a moment and help me out. A very humble request to you gurus. I'm new to Unix and I have started learning Unix. I have this project which is way to advanced for me. File format: CSV file File has four columns with no header... (8 Replies)
Discussion started by: arvindosu
8 Replies

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

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

Converting rows to columns in csv file

Hi, I have a requirement to convert rows into columns. data looks like: c1,c2,c3,.. r1,r2,r3,.. p1,p2,p3,.. and so on.. output shud be like this: c1,r1,p1,.. c2,r2,p2,.. c3,r3,p3,.. Thanks in advance, (12 Replies)
Discussion started by: Divya1987
12 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

Save output of updated csv file as csv file itself

Hi, all I want to sort a csv file based on timestamp from oldest to newest and save the output as csv file itself. Here is an example of my csv file. test.csv SourceFile,DateTimeOriginal /home/intannf/foto/IMG_0739.JPG,2015:02:17 11:32:21 /home/intannf/foto/IMG_0749.JPG,2015:02:17 11:37:28... (10 Replies)
Discussion started by: refrain
10 Replies

9. Shell Programming and Scripting

Save output of updated csv file as csv file itself, part 2

Hi, I have another problem. I want to sort another csv file by the first field. result.csv SourceFile,Airspeed,GPSLatitude,GPSLongitude,Temperature,Pressure,Altitude,Roll,Pitch,Yaw /home/intannf/foto5/2015_0313_090651_219.JPG,0.,-7.77223,110.37310,30.75,996.46,148.75,180.94,182.00,63.92 ... (2 Replies)
Discussion started by: refrain
2 Replies
FILE2BRL(1)							   User Commands						       FILE2BRL(1)

NAME
file2brl - manual page for file2brl (liblouisutdml) 2.2.0 SYNOPSIS
file2brl [OPTION] [inputFile] [outputFile] DESCRIPTION
Translate an xml or a text file into an embosser-ready braille file. This includes translation into grade two, if desired, mathematical codes, etc. It also includes formatting according to a built-in style sheet which can be modified by the user. If inputFile is not specified or '-' input is taken from stdin. If outputFile is not specified the output is sent to stdout. -h, --help display this help and exit -v, --version display version information and exit -f, --config-file name a configuration file that specifies how to do the translation -b, --backward backward translation -r, --reformat reformat a braille file -T, --text Treat as text even if xml -p, --poorly-formatted translate a poorly formatted file -t, --html html document, not xhtml -C, --config-setting specify particular configuration settings They override any settings that are specified in a config file -l, --log-file write errors to file2brl.log instead of stderr AUTHOR
Written by John J. Boyer. REPORTING BUGS
Report bugs to <john.boyer@abilitiessoft.com>. COPYRIGHT
Copyright (C) 2009 ViewPlus Technologies, Inc. and JJB Software, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
The full documentation for file2brl is maintained as a Texinfo manual. If the info and file2brl programs are properly installed at your site, the command info liblouisutdml should give you access to the complete manual. file2brl (liblouisutdml) 2.2.0 March 2012 FILE2BRL(1)
All times are GMT -4. The time now is 08:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy