bbruman bbruman - 1 year ago 67
MySQL Question

Empty Lines at End of TSV file Creating Empty Column in MySQL Load Data Infile

What's the best way to amend this issue, in either MySQL or PHP?

I'm using the Amazon PHP SDK, GetReport function.

$intry = (stream_get_contents($request->getReport()) . "\n");
$merchantalldata = '_GET_MERCHANT_LISTINGS_ALL_DATA_' . $today0 . '.tsv';


Always on my returned TSV, it's always the same:

enter image description here
enter image description here

How can I fix this issue, whether in the TSV file itself, via PHP, or disallow this blank entry from being inserted in the MySQL database?

Answer Source

Remove the "\n" in the stream_get_contents() call, then trim() if needed:

$intry = trim(stream_get_contents($request->getReport()));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download