Guys,
I have a line like this: 109;201;1099010
and as you see that first field 109 and the last field starts with 109. I need to cut the rest in the last field after 109 which is 9010
How to do it? (2 Replies)
Hello,
In a shell script I am writing I execute this command:
uniq -c names1.tmp > names2.tmp
In names2.tmp I get these results:
4 user
2 username
1 users
1 veriano
1 victoria
I need to isolate the names in this file and put it in another file. However it seems that the number... (7 Replies)
Hello,
I had posted earlier about printing fields using AWK, but now I have a slightly different problem. I have text files in the format:
1*2,3,4,5
and wish to print the first, third, and fifth fields, including the asterisk and commas. In other words, after filtering it should look... (1 Reply)
Hi Everyone,
I have one a.txt:
a b 001 c
b b 002 c
c c, not 002 c
The output should be
001
002
002
If i use cut -f 3 -d' ', this does not work on the 3rd line, so i thought is any way to cut the field counting from the end? or any perl thing can do this?:confused:
... (3 Replies)
hi all
i am need to cut the name of the file which i am entering in the comand line. say abc.txt is the name of the file i need to cut only the "abc" part. when i try doing this(using cut -f1) i am getting the data that s present inside the file and the file name. pls help.... (3 Replies)
Hello,
I have got a log file and would need to write a script to cut the every first and second fields of every third line.
Job Name : dummytextd_v1
Status : KILLED
TIMEDOUT 2011-05-01 05:33
Job Name : dummyttx_v1
Status : KILLED
TIMEDOUT 2011-05-03 02:33
Job Name :... (4 Replies)
Hello,
I would like to cut the first field and the 2 last fields from the string.Please help.
Here is the example of the string.DL_FUND_FULL_20190605.txt
DL_FUND_HIS_DEL_20190605.txt
DL_FUND_HIS_TMP_DEL20190605.txt
Please noted that
DL_ --> Every files have the prefix like this.... (3 Replies)
Discussion started by: palita2601
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)