Sponsored Content
Top Forums UNIX for Advanced & Expert Users Urgent! need help! how to convert this file into comma delimited format Post 302348340 by natalie23 on Friday 28th of August 2009 03:29:41 AM
Old 08-28-2009
Urgent! need help! how to convert this file into comma delimited format

Hi experts,
I need urget help! I have the a text file with this format:

Types of fruits
Name of fruits
1,1
Farm_no,1
apple,1
pineapple,1
grapes,1
orange,1
banana,1
2,2--->this is the record seperator
Farm_no,2
apple,1
pineapple,1
grapes,3
orange,2
banana,1
3,3--->this is the record seperator
Farm_no,3
apple,4
pineapple,2
grapes,3
orange,2
banana,0

I need to parse this txt file into csv format.

The output need to look like this:

FARM_no,apple,pineapple,grapes,orange,banana
1,1,1,1,1,1
2,1,1,3,2,1
3,4,2,3,2,0

Anyone have any idea?Please help!

Thank a lot!

Thanks.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert comma text file to Column in html format

I am trying to generate a report with below file : File1 : EQADM,edrtere9-phys,8122caef0,gpatmon,/bin/ksh,nuten Erick EQADM,edrtere11-phys,8227caef0,gpatmon,/bin/ksh,nuten Erick EQADM,edrtere3-phys,822caef0,gpatmon,/bin/ksh,nuten Erick can you help me convert it to html and add... (9 Replies)
Discussion started by: sriram003
9 Replies

2. Shell Programming and Scripting

how to convert this file into comma delimited format

Hi experts, I need urget help! I have the a text file with this format: Types of fruits Name of fruits 1,1 Farm_no,1 apple,1 pineapple,1 grapes,1 orange,1 banana,1 2,2--->this is the record seperator Farm_no,2 apple,1 pineapple,1 grapes,3 orange,2 banana,1 3,3--->this is the... (1 Reply)
Discussion started by: natalie23
1 Replies

3. Shell Programming and Scripting

Urgent - Comma delimited file comparision.

Query: There are two files as below – /home/rgupta/input/file.txt.arch (source file) /home/rgupta/output/file.txt (destination file) Files details are attached for the reference. Scenario: File /home/rgupta/input/file.txt.arch picked up by an application xyz. Application xyz does... (1 Reply)
Discussion started by: ravigupta2u
1 Replies

4. UNIX for Dummies Questions & Answers

How to convert a text file into tab delimited format?

I have a text file that made using text editor in Ubuntu. However the text file is not being recognized as space or tab delimited, the formatting seems to be messed up. How can I convert the text file into tab delimited format? (3 Replies)
Discussion started by: evelibertine
3 Replies

5. Shell Programming and Scripting

how to convert comma delimited file to tab separator

Hi all, How can i convert comma delimited .csv file to tab separate using sed command or script. Thanks, Krupa (4 Replies)
Discussion started by: krupasindhu18
4 Replies

6. UNIX for Dummies Questions & Answers

appending a command to print a file in a comma delimited format

Hi everyone, i have a file that I had grep'd from something else lets call it file1.txt which consists variable files and lines due to different scenarios/inputs 1782 9182 fe35 ac67 how can I print this in this manner? 1782,9182,fe35,ac67 also if i had piped the new output... (2 Replies)
Discussion started by: prodigy06
2 Replies

7. Shell Programming and Scripting

Need a script to convert comma delimited files to semi colon delimited

Hi All, I need a unix script to convert .csv files to .skv files (changing a comma delimited file to a semi colon delimited file). I am a unix newbie and so don't know where to start. The script will be scheduled using cron and needs to convert each .csv file in a particular folder to a .skv... (4 Replies)
Discussion started by: CarpKing
4 Replies

8. UNIX for Dummies Questions & Answers

How to convert a comma delimited string to records or lines of text?

Hi, I am not sure if I've posted this question before. Anyway, I previously asked about converting lines of text into a comma delimited string. Now I am needing to do the other way around ... :( :o Can anyone advise how is this possible? Example as below: Converting records/lines to... (2 Replies)
Discussion started by: newbie_01
2 Replies

9. Shell Programming and Scripting

UNIX/PERL script to convert XML file to pipe delimited format

Hello, I need to get few values from a XML file and output needs to be written in another file with pipe delimited format. The Header & Footer of the Pipe Delimited file will be constant. The below is my sample XML file. I need to pull the values in between the XML tags <Operator_info to... (15 Replies)
Discussion started by: karthi1305561
15 Replies

10. Shell Programming and Scripting

Linux convert Comma delimited file to pipe

I have file in linux with comma delimited and string fields in double quotations ", I need to convert them to pipe delimiter please share your inputs. Example: Input: "2017-09-30","ACBD,TVF","01234",NULL,18,NULL,"686091802","BANK OF ABCD, LIMITED, THE",790456 Output: ... (4 Replies)
Discussion started by: shieksir
4 Replies
LIMITITERATOR(3)							 1							  LIMITITERATOR(3)

The LimitIterator class

INTRODUCTION
The LimitIterator class allows iteration over a limited subset of items in an Iterator. CLASS SYNOPSIS
LimitIterator LimitIteratorextends IteratorIteratorOuterIterator Methods o public LimitIterator::__construct (Iterator $iterator, [int $offset], [int $count = -1]) o public mixed LimitIterator::current (void ) o public Iterator LimitIterator::getInnerIterator (void ) o public int LimitIterator::getPosition (void ) o public mixed LimitIterator::key (void ) o public void LimitIterator::next (void ) o public void LimitIterator::rewind (void ) o public int LimitIterator::seek (int $position) o public bool LimitIterator::valid (void ) EXAMPLES
Example #1 LimitIterator usage example <?php // Create an iterator to be limited $fruits = new ArrayIterator(array( 'apple', 'banana', 'cherry', 'damson', 'elderberry' )); // Loop over first three fruits only foreach (new LimitIterator($fruits, 0, 3) as $fruit) { var_dump($fruit); } echo " "; // Loop from third fruit until the end // Note: offset starts from zero for apple foreach (new LimitIterator($fruits, 2) as $fruit) { var_dump($fruit); } ?> The above example will output: string(5) "apple" string(6) "banana" string(6) "cherry" string(6) "cherry" string(6) "damson" string(10) "elderberry" PHP Documentation Group LIMITITERATOR(3)
All times are GMT -4. The time now is 06:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy