dpw43061 2016-11-15 18:57
浏览 87
已采纳

TSV文件末尾的空行在MySQL加载数据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()) . "
");
$merchantalldata = '_GET_MERCHANT_LISTINGS_ALL_DATA_' . $today0 . '.tsv';
file_put_contents($merchantalldata,$intry);

$sql = "LOAD DATA LOCAL INFILE '_GET_MERCHANT_LISTINGS_ALL_DATA_" . $today00 . ".tsv' INTO TABLE . . . . "

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?

  • 写回答

1条回答 默认 最新

  • dsk88199 2016-11-15 19:19
    关注

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

    $intry = trim(stream_get_contents($request->getReport()));
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services