Replacing text in a .csv file using Perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Replacing text in a .csv file using Perl
# 8  
Old 02-16-2009
the file is actually .csv file and i just changed the file extension to .txt (I assumed it would be easier to manipulate)... here is an actual line from .txt file:

Code:
"12722"	"New"	"Major"	"Unassigned"	"Asset Manager"	"Unassigned"	"7.1.1"	""	"library"	"Bruce Borth"	"Jan 7, 2009 10:27 AM"	"Jan 11, 2009 1:50 PM"	"Unassigned"	"Library function does not have the ability to create a library without enabling it - Liraries do not depend on other lib messge missing details"	""	""	"Defect"

# 9  
Old 02-16-2009
Works OK for me:

Code:
my $var = qq{"12722"	"New"	"Major"	"Unassigned"	"Asset Manager"	"Unassigned"	"7.1.1"	""	"library"	"Bruce Borth"	"Jan 7, 2009 10:27 AM"	"Jan 11, 2009 1:50 PM"	"Unassigned"	"Library function does not have the ability to create a library without enabling it - Liraries do not depend on other lib messge missing details"	""	""	"Defect"};
$var =~ tr/"//d; 
$var =~ s/\t/,/g;
print $var;

output:

Code:
12722,New,Major,Unassigned,Asset Manager,Unassigned,7.1.1,,library,Bruce Borth,Jan 7, 2009 10:27 AM,Jan 11, 2009 1:50 PM,Unassigned,Library function does not have the ability to create a library without enabling it - Liraries do not depend on other lib messge missing details,,,Defect

# 10  
Old 02-17-2009
I think my problem is with the file format itself. Does anyone know how i can change the file format to UNIX text format?

preferably without the use of any application just on the MS-DOS command line
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

TEXT to CSV using Perl

Hi Folks Need some help with this and my Perl isnt the hottest I also have text::csv installed on my perl install The large text with a few million entries is in a format below example text file Fig Leafs Cake No: 0000001 Author: King s. Record No: 995-34343-232-232... (5 Replies)
Discussion started by: messiah1
5 Replies

2. Shell Programming and Scripting

Replacing text in Perl given by command line

Hi I need to write a Perl script that the file given as first argument of the command line that will find all occurrences of the string given as the third argument of the command line and replace with the string given as the fourth argument. Name newfound file is specified as the second... (3 Replies)
Discussion started by: nekoj
3 Replies

3. Shell Programming and Scripting

Replacing comma with in double quotes in a csv file

Hello, I need to read a csv file and I am trying to replace a comma with a text DSEE?DSEE. Example Input "Chapter","NewTrains, "oldTrains","Delayed",10,"London" "Chapter","Newbuses,oldbuses","On Time",20,"London" Output "Chapter","NewTrainsDSEE?DSEE... (5 Replies)
Discussion started by: venkatvani
5 Replies

4. UNIX for Advanced & Expert Users

Replacing the comma in .csv file in unix

Hi All, Could some one help me on one of my requirement below: I have a sequential file with 4fields in it and it is a comma (,) seperated file. Delimeter is 'comma'. But in of the file column for ex: 3rd column it is 'Description' (column name) I am getting the values with commas.... (6 Replies)
Discussion started by: eskay_s
6 Replies

5. Shell Programming and Scripting

Format text to bold from perl script to csv

Hi everyone, is there any way in perl using which we can print the selective words in bold when we write the output to a csv file? Please find the example below 1. Filename: A 2. name age 12 3. city add 23 Line1 should only be bold. Outputs from other files being read in the... (2 Replies)
Discussion started by: ramakanth_burra
2 Replies

6. Shell Programming and Scripting

selective replacing text using sed/perl

Hi, I have the following text which I want to search and replace using perl and sed. I would appreciate any help. Please notice the file contains schema name with a single dot and a double dot . &&WEBDIR_SCHEMA. and &&WEBDIR_SCHEMA .. } I would like to change it to the acutal schema... (5 Replies)
Discussion started by: jville
5 Replies

7. Shell Programming and Scripting

Replacing strings in csv file.

Hi, I have a problem.. 1) I have a file that contains the lines as below : VRF-TM_DummyLab/mse02.lab,mse02.lab,ge-2/0/7.222 VRF-EMS_HUAWEI_MSAN_208/mse01.lab,mse01.lab,xe-1/0/0.208 2) I need a method to read this file, line by line from :... (5 Replies)
Discussion started by: msafwan82
5 Replies

8. Shell Programming and Scripting

Replacing strings in a log file and saves as a new csv

Hello Im new here.I need to replace strings and change it into csv format, or at least saves the file as csv if that would work :p. Heres an example of my scenario 1) I have a log file, named abc.log, and its like a txt based file anyway, and the content looks like this ... (2 Replies)
Discussion started by: tententen
2 Replies

9. UNIX for Dummies Questions & Answers

Replacing characters in csv file

Hello all, This is my first post here, so please excuse me if this question is too obvious or has been asked before. I am new to Unix and although I tried to search your forum for the answer to my question, I could not find an answer that would help me. I have a 500MB csv file with numeric values... (1 Reply)
Discussion started by: finwhiz
1 Replies

10. Shell Programming and Scripting

replacing commas with tilde in csv file.

hello all, i have a comma delimited file. i want to replace the commas in the file with the tilde symbol using sed. how can i do this? thanks. (4 Replies)
Discussion started by: femig
4 Replies
Login or Register to Ask a Question