CSV's having "" removed #255
-
Hi there, I'm using .csv files with encapsulated headers and values, like "Header", "Header2" etc, |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
Hey, could you maybe provide some simple example of csv file and what result do you expect after reading it so I can look into this? |
Beta Was this translation helpful? Give feedback.
-
Example of inputs:
Example of outputs:
|
Beta Was this translation helpful? Give feedback.
-
This happens all the time, even with the most minimum flows. CSV::from( ->unpack row CSV::to( |
Beta Was this translation helpful? Give feedback.
-
This is pretty much how CSV works. When flow is loading CSV file into memory it's using PHP function fgetcsv. It's that function that is removing Input
Code <?php
use Flow\ETL\DSL\CSV;
use Flow\ETL\DSL\Stream;
use Flow\ETL\DSL\Transform;
use Flow\ETL\Flow;
require __DIR__ . '/../vendor/autoload.php';
(new Flow())
->read(CSV::from(Stream::local_file(__DIR__ . '/issue289.csv')))
->rows(Transform::array_unpack('row'))
->drop("row")
->write(CSV::to(Stream::local_file(__DIR__ . '/issue289_new.csv'), true, false, ',', "'"))
->run(); Output
For the better contrast, I changed Could you maybe elaborate on why do you want to keep |
Beta Was this translation helpful? Give feedback.
-
Also if you would like to just move file, line by line, from one place to another, you can use Text adapter that was just released. It will read file line by line and then write it line by line, by default not changing/removing anything. |
Beta Was this translation helpful? Give feedback.
-
I'm closing this issue for now, if my answer did not explain the reported behavior and you are looking for something else please let me know. |
Beta Was this translation helpful? Give feedback.
This is pretty much how CSV works.
When flow is loading CSV file into memory it's using PHP function fgetcsv. It's that function that is removing
"
and when you are dumping output to a regular file only values/columns withspace
will be surrounded by"
which is the default enclosure.Input
Code