I have a csv file with lines like the followings
123456,"ABC CO., LTD","XXX"
789012,"DEF LIMITED", "XXX"
before I bcp this file to database, the comma in "CO.," need to be removed first.
My script is cat <filename> | sed 's/"CO.,"/"CO."/g'
but it doesn't work. Can anyone here able to... (2 Replies)
Hi,
I have a requirement to replace the comma's inside the double quotes. The comma's inside the double quotes will get changed dynamically.
Input Record:
"Washington, DC,Prabhu,aju",New York
Output Record:
"Washington| DC|Prabhu|aju",New York
I tried with the below command but it... (3 Replies)
Hello, I am using awk to match text in a tab separated field and am able to do so when matching the exact word. My problem is that I would like to match any sequence of text in the tab-separated field without having to match it all. Any help will be appreciated. Please see the code below.
awk... (3 Replies)
Hi... I can't find my little red AWK book and it's been a long while since I've awk'd. But I need to take a CSV file and convert the first word of the fifth field to its own field by replacing a space with a comma.
This is for importing a spreadsheet of issues into JIRA...
Example:
a line... (9 Replies)
I am trying to parse the input in awk to include the |gc= in $4 but am not able to. The below is close:
awk so far:
awk '{sub(/\|]+]++/, ""); print }' input.txt Input
chr1 955543 955763 AGRN-6|pr=2|gc=75 0 +
chr1 957571 957852 AGRN-7|pr=3|gc=61.2 0 +
chr1 970621 ... (7 Replies)
We have a csv file as mentioned below and the requirement is to change the date format in file as mentioned below.
Current file (file.csv)
----------------------
empname,date_of_join,dept,date_of_resignation
ram,08/09/2015,sales,21/06/2016
"akash,sahu",08/10/2015,IT,21/07/2016
... (6 Replies)
Hi Experts,
Please support
I have below data in file in comma seperated, but 4th column is containing comma in between numbers, bcz of which when i tried to parse the file the column 6th value(5049641141) is being removed from the file and value(222.82) in column 5 becoming value of column6.
... (3 Replies)
Discussion started by: as7951
3 Replies
LEARN ABOUT PHP
fputcsv
FPUTCSV(3) 1 FPUTCSV(3)fputcsv - Format line as CSV and write to file pointerSYNOPSIS
int fputcsv (resource $handle, array $fields, [string $delimiter = ","], [string $enclosure = '"'], [string $escape_char = "
DESCRIPTION fputcsv(3) formats a line (passed as a $fields array) as CSV and write it (terminated by a newline) to the specified file $handle.
PARAMETERS
o $handle
-The file pointer must be valid, and must point to a file successfully opened by fopen(3) or fsockopen(3) (and not yet closed by
fclose(3)).
o $fields
- An array of values.
o $delimiter
- The optional $delimiter parameter sets the field delimiter (one character only).
o $enclosure
- The optional $enclosure parameter sets the field enclosure (one character only).
o $escape_char
- The optional $escape_char parameter sets the escape character (one character only).
RETURN VALUES
Returns the length of the written string or FALSE on failure.
CHANGELOG
+--------+---------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------+
| 5.5.4 | |
| | |
| | The $escape_char parameter was added |
| | |
+--------+---------------------------------------+
EXAMPLES
Example #1
fputcsv(3) example
<?php
$list = array (
array('aaa', 'bbb', 'ccc', 'dddd'),
array('123', '456', '789'),
array('"aaa"', '"bbb"')
);
$fp = fopen('file.csv', 'w');
foreach ($list as $fields) {
fputcsv($fp, $fields);
}
fclose($fp);
?>
The above example will write the following to file.csv:
aaa,bbb,ccc,dddd
123,456,789
"""aaa""","""bbb"""
NOTES
Note
If PHP is not properly recognizing the line endings when reading files either on or created by a Macintosh computer, enabling the
auto_detect_line_endings run-time configuration option may help resolve the problem.
SEE ALSO fgetcsv(3).
PHP Documentation Group FPUTCSV(3)