Sponsored Content
Top Forums Shell Programming and Scripting How to remove unwanted commas from a .csv file? Post 303024294 by Don Cragun on Friday 5th of October 2018 11:16:17 AM
Old 10-05-2018
Whenever you start a thread in the Shell Programming and Scripting forum, please tell us what operating system and shell you're using!

And give us a clear explanation of what it is that you want to do. The fields in your CSV file seem to be separated by three character <double-quote><comma><double-quote> sequences.

You say you want to remove unwanted <comma>s; but you don't explain why the <comma>s in field six are unwanted, why both a <comma> and a <space> are unwanted in field four, and you don't explain why the <comma>s in other fields are not unwanted. You didn't say anything in your description about removing unwanted <space>s. (Note that the script vgersh99 suggested doesn't produce the output you say you want because it didn't remove the <space> after the <comma> you said you wanted removed in field four.)

With well over 100 posts in this forum, you should know by now that we expect you to show us what you have tried to solve this problem on your own. We want to help you learn how to do things like this on your own; not act as your unpaid programming staff.
This User Gave Thanks to Don Cragun For This Post:
 

10 More Discussions You Might Find Interesting

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

2. Shell Programming and Scripting

Remove duplicate commas after exporting excel file to csv

Hello everyone I'm new here and this is my first post so first of all I want to say that this is a great forum and I have managed to found most of my answers in these forums : ) So with that I ask you my first question: I have an excel file which I saved as a csv. However the excel file... (3 Replies)
Discussion started by: Spunkerspawn
3 Replies

3. Shell Programming and Scripting

shell script to remove extra commas from CSV outp file

Name,,,,,,,,,,,,,,,,,,,,Domain,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Contact,Phone,Email,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Location -----------------------,------------------------------------------------,-------,-----,---------------------------------,------------------------------------ ----... (1 Reply)
Discussion started by: sreenath1037
1 Replies

4. Shell Programming and Scripting

CSV with commas in field values, remove duplicates, cut columns

Hi Description of input file I have: ------------------------- 1) CSV with double quotes for string fields. 2) Some string fields have Comma as part of field value. 3) Have Duplicate lines 4) Have 200 columns/fields 5) File size is more than 10GB Description of output file I need:... (4 Replies)
Discussion started by: krishnix
4 Replies

5. Shell Programming and Scripting

Remove leading commas in the file

Hi , I have a file with below records 965382,10310858,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 767010,10217614,3,10217616,10217622,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,... (4 Replies)
Discussion started by: vputtas@gmail.c
4 Replies

6. Shell Programming and Scripting

Adding Extra Commas to a CSV file

Trying in this forum. Not sure if it is permitted.... but in need of help. Please find the requirements in the below link. https://www.unix.com/unix-dummies-questions-answers/191503-add-extra-commas-csv-file-2.html#post302665179 Thanks in Advance. (1 Reply)
Discussion started by: chillblue
1 Replies

7. UNIX for Dummies Questions & Answers

To Add extra commas to a CSV file using 2 files...

Hi , Based on my previous requirement the code works fine for comma as delimiter. Now my Req is widened up a bit .. There will be two set of files .. one with comma as delimiter and other with semi-colon ; as delimiter. Second Sample file. With Double Quotes (Semi-Colon... (1 Reply)
Discussion started by: chillblue
1 Replies

8. UNIX for Dummies Questions & Answers

To Add extra commas to a CSV file.

Hi All, I got this requirement to process a complex CSV file. Eg File. Line 1: Name:,XYz Line 2: Age:,15 Line 3: Grade:,7 Line 4: Line 5: English, Maths, Science,Spanish Line 6:10,11,13,14 As you can see the maximum column is 4 . The file i need to make is Line 1: Name:,XYz,,... (12 Replies)
Discussion started by: chillblue
12 Replies

9. Shell Programming and Scripting

Shell script that should remove unnecessary commas between double quotes in CSV file

i have data as below 123,"paul phiri",paul@yahoo.com,"po.box 23, BT","Eco Bank,Blantyre,Malawi" i need an output to be 123,"paul phiri",paul@yahoo.com,"po.box 23 BT","Eco Bank Blantyre Malawi" (5 Replies)
Discussion started by: mathias23
5 Replies

10. UNIX for Beginners Questions & Answers

Removing commas from CSV file

Hi I'm creating a sh script to generate a csv file. The CSV contains the values from a sql table. The content looks this: a,b,c,c2,c3,,,,,,,,,,,d,e I have some code that can separate the fields using the comma as delimiter, but some values actually contain commas, such as... (2 Replies)
Discussion started by: preema
2 Replies
read_reading(3) 						  Staden Package						   read_reading(3)

NAME
read_reading, fread_reading - Read a trace file into a Read structure. SYNOPSIS
#include <Read.h> Read *read_reading( char *filename, int format); Read *fread_reading( FILE *fp, char *filename, int format); DESCRIPTION
These functions read trace files into a Read structure. A variety of formats are supported including ABI, ALF and SCF. (Note that the first two are only supported when the library is used as part of the Staden Package.) Additionally, support for reading the plain (old) staden format files and Experiment files is included. Compressed trace files may also be read. Decompression is performed using either gzip -d or uncompress and is written to a temporary file for further processing. The temporary file is then read and removed. When reading an experiment file the trace file referenced by the LN and LT line types is read. The QL, QR (left and right quality clips), SL and SR (left and right vector clips) are taken from the Experiment file to produce the cutoff information held within the Read struc- ture. The orig_trace field of the Read structure will then contain the pointer to the experiment file structure and the orig_trace_format field will be set to TT_EXP. The functions allocate a Read structure which is returned. To deallocate this structure use the read_deallocate() function. read_reading() reads a trace from the specified filename and format. Formats available are TT_SCF, TT_ABI, TT_ALF, TT_PLN, TT_EXPand TT_ANY. Specifying format TT_ANY will attempt to automatically detect the corret format type by analysing the trace file for magic numbers and composition. The format field of the structure can then be used to determine the real trace type. fread_reading() reads a trace from the specified file pointer. The filename argument is used for setting the trace_name field of the resulting structure, and for error messages. Otherwise the function is identical to the read_reading() function. The Read structure itself is as follows. typedef uint_2 TRACE; /* for trace heights */ typedef struct { int format; /* Trace file format */ char *trace_name; /* Trace file name */ int NPoints; /* No. of points of data */ int NBases; /* No. of bases */ /* Traces */ TRACE *traceA; /* Array of length `NPoints' */ TRACE *traceC; /* Array of length `NPoints' */ TRACE *traceG; /* Array of length `NPoints' */ TRACE *traceT; /* Array of length `NPoints' */ TRACE maxTraceVal; /* The maximal value in any trace */ /* Bases */ char *base; /* Array of length `NBases' */ uint_2 *basePos; /* Array of length `NBases' */ /* Cutoffs */ int leftCutoff; /* Number of unwanted bases */ int rightCutoff; /* Number of unwanted bases */ /* Miscellaneous Sequence Information */ char *info; /* misc seq info, eg comments */ /* Probability information */ char *prob_A; /* Array of length 'NBases' */ char *prob_C; /* Array of length 'NBases' */ char *prob_G; /* Array of length 'NBases' */ char *prob_T; /* Array of length 'NBases' */ /* The original input format data, or NULL if inapplicable */ int orig_trace_format; void *orig_trace; } Read; RETURN VALUES
On successful completion, the read_reading() and fread_reading() functions return a pointer to a Read structure. Otherwise these functions return NULLRead (which is a null pointer). SEE ALSO
write_reading(3), fwrite_reading(3), deallocate_reading(3), scf(4), ExperimentFile(4) read_reading(3)
All times are GMT -4. The time now is 01:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy