我正在编写一个Ruby脚本来生成CSV文件.我的理解是CSV文件中的每一行都是表中的一行.
现在我的脚本生成了这样的东西
Vancouver, Calgary,
Routes1,
Routes2,
Routes3,
Vancouver, Toronto
etc,
etc,
etc
Run Code Online (Sandbox Code Playgroud)
但我需要它让它看起来像这样导入数据库
Vancouver, Calgary, Routes1, Routes2, Routes3
Vancouver, Toronto, etc etc etc..
Run Code Online (Sandbox Code Playgroud)
我的脚本的工作原理是从原始数据中查找温哥华和卡尔加里,其中包含不同文件中路径的位置.然后脚本转到那些文件以查找实际路由.每次找到路径(例如Route1)时,脚本都会使用"puts"方法输出它.问题是每个输出都在一个新的行上.
有没有办法在使用"puts"命令时禁止新行命令?