如何使用JAVA更新S3文件中的CSV文件的标头

huangapple go评论87阅读模式
英文:

How to update Headers of CSV file in S3 file using JAVA

问题

我在S3位置上有一个CSV文件,具有以下标题:

S3输入文件: <br/>
number|dob|name|time|addr <br/>
1|8月5日|山姆|下午5点|美国

期望的输出:

SrNumber|DOB|Name|Time|Address <br/>
1|8月5日|山姆|下午5点|美国

我需要重命名/更新这些标题,并将CSV文件再次放回该位置。<br />
你能指导我如何使用JAVA实现这个目标吗? <br />
注意:文件可能包含数百万条记录。

英文:

I have a csv on S3 Location with below Headers:

Input S3 file: <br/>
number|dob|name|time|addr <br/>
1|aug 5|sam|5 pm|US

e.g output Expected:

SrNumber|DOB|Name|Time|Address <br/>
1|aug 5|sam|5 pm|US

I need to rename/update the headers and drop the csv again to that location. <br />
Can you guide me achieve this using JAVA? <br />
Note: File can contain Millions of records.

答案1

得分: 0

一个好的起点是使用内置的 Scanner 类将 CSV 输入文件读入到您的程序中。从那里,您可以使用 FileWriter 类将更新写回文件。
导入部分如下:

  • import java.util.Scanner;
  • import java.io.FileWriter;
英文:

A good place to start would be using the builtin Scanner class to ready the CSV input file in to your program. From there you could use the FileWriter class to write your updates back out to a file.
the imports are:

  • import java.util.Scanner;
  • import java.io.FileWriter;

huangapple
  • 本文由 发表于 2020年8月21日 17:14:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/63519946.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定