Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我已经阅读了文档,但仍然看不到如何定位单个单元格并将字符串预先或附加到单元格内容。文件相当大,如果重要的话(90MB)。
CSV:
2.22,3.33,4.44,5.55 6.66,7.77,8.88,9.99
我需要这个输出:
%text2.22%,%text3.33%,%text4.44%,%text5.55% %text6.66%,%text7.77%,%text8.88%,%text9.99%
你一定要使用fastercsv吗?如果您的输入真的像您展示的那样简单,那么以下内容就足够了:
fastercsv
pre_text = '%text' post_text = '%' File.open('outfile.csv', 'w') {|of| File.readlines('input_file.csv').each {|line| of.puts line.strip.split(',').map{|x| pre_text + x + post_text}.join(',') } }