Can't use Text::CSV... any sample code out there?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Can't use Text::CSV... any sample code out there?
# 1  
Old 09-24-2009
Can't use Text::CSV... any sample code out there?

I was looking at a library that lets me parse comma delimited csv files without a problem, but unfortunately, I'm not allowed to make use of that library. I understand that the library probably does something similar to a string split(), but I don't quite know what kind of regular expression is being used for something that's within double quotes, but contains a comma while the line is comma delimited. for instance:

a, "b", "a,b,c", d

Should only be 4 columns. What kind of regular expression would indicate this?

Thanks for your answers in advance.
# 2  
Old 09-25-2009
i think you should split on commas, and then iterate over the resulting array
in the loop, check for elements that start with double quote, and concatenate to it all ensuing elements until the one that ends with "
if you know the number of columns in advance, much easier, if not still doable.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert text to csv

Hi, Is there somebody there to post an idea on how to convert this 5 liner row to 1 liner or tab delimiter to be import to database. Here the text file format: Description: Description1 Link: https://www.google.com Date: June 2, 2018 Time: 00:07:44 Age: 1 days ago Description:... (2 Replies)
Discussion started by: lxdorney
2 Replies

2. Shell Programming and Scripting

Convert text to CSV

Hi Gurus I need urgent help to convert a flat log file into csv format to load into database. Log looks like: a=1 b=2 c=3 a=4 b=5 c=6 Only the values at right side of = will come into csv and it should create a new line once it receives "a" field. (8 Replies)
Discussion started by: sandipjee
8 Replies

3. Shell Programming and Scripting

text to csv conversion

Thank u every body ......just need a help so that a text file needs to be converted into CSV............. my log file is as follows Host scsi3: usb-storage Vendor: Maxtor Product: OneTouch III Serial Number: 044303E5 Protocol: Transparent SCSI Transport: Bulk ... (4 Replies)
Discussion started by: tangotango
4 Replies

4. Shell Programming and Scripting

sample code to display mounted devices

Hi all I need to write shell script to list out the mounted devices for a particular user. As i am new to shell script please help me. Here the problem is sometime unmounted devices also will be displayed in fstab. How to rectify that? Can anybody help me? Regards Ilamathi (0 Replies)
Discussion started by: ilamathi
0 Replies

5. Solaris

Java api/sample code for sftp

I'm trying to find an api for Java to send/receive files via sftp. There are some available for purchase out there such as JScape, but I was hoping to find a free one. Does anyone know of one? I would also like to find an open source java example application that can send files via sftp. ... (2 Replies)
Discussion started by: JohnRodey
2 Replies

6. Shell Programming and Scripting

Text to CSV

Hi, My access log looks like this... 192.168.50.184 - - "GET /ATIM_LATEST/ABC/ HTTP/1.1" 200 522 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.13) Gecko/2009073022 Firefox/3.0.13" 192.168.50.184 - - "GET /ATIM_LATEST/ABC/ATIM/syncdepot.php HTTP/1.1" 200 1463... (5 Replies)
Discussion started by: shantanuo
5 Replies

7. Shell Programming and Scripting

Text to csv

Hi, I have a document with a lot of data, it is structured like this, UNIQUESTRING To be acquited of a crime is to be deemed to be innocent of the charges after a court hearing. This is different from a <a href=lawglos_Discharge.html>Discharge</a>, where the case is never heard. In... (1 Reply)
Discussion started by: lawstudent
1 Replies

8. UNIX and Linux Applications

Need the sample code for implementation of SFTP

Hi we need to implement SFTP through unix shell scripts. I have seen many posts, in which there is discussion about non-interactive,automated SFTP. Can anyone please send me the sample code for SFTP shell script. We are using SFTP to transfer the files from the host server to the target... (10 Replies)
Discussion started by: kumarm
10 Replies

9. Shell Programming and Scripting

Sample Unix script file to convert .xml to .csv

Dear all, Can you send me a script file the changes .xml to .csv file. Thanks, Srinivasa (4 Replies)
Discussion started by: srinivasaphani
4 Replies
Login or Register to Ask a Question