简体   繁体   English

如何将字符串列表(斜杠分隔值)作为 CSV 发布到 Amazon S3?

[英]How to publish a list of strings (of slash seperated values) to Amazon S3 as CSV?

I have a list of Strings as follows->我有一个字符串列表如下->

List<String> x=new ArrayList<String>();
Each string inside the list is of the following format -(They are slash separated)
String 1-Name/City/Age/Hobbie
String 2-Ross/Sydney/35/Painting
String 3-Joey/Wellington/40/Dancing
and so on

How to publish these strings to a S3 Bucket as a csv file?如何将这些字符串作为 csv 文件发布到 S3 存储桶?

There should be four columns in the sheet Name,City,Age,Hobbie工作表中应该有四列 Name,City,Age,Hobbie

First you need to create.csv file from your input data.首先,您需要从输入数据中创建.csv 文件。 You can do it by writing your own logic to separate string and then writing it to file with the help of PrintWriter class of java.io package or you can you third party library which makes your life easy. You can do it by writing your own logic to separate string and then writing it to file with the help of PrintWriter class of java.io package or you can you third party library which makes your life easy. Here is the list of libraries you can use.这是您可以使用的库列表。

  • Apache Commons CSV: Apache's CSV offering for working with CSV Files Apache Commons CSV:Apache 的 CSV 产品与 ZCC8D68C551C4A9A4DEDED7 文件一起使用
  • Open CSV: Another popular and actively-maintained CSV library打开 CSV:另一个流行且积极维护的 CSV 库
  • Flatpack: An open-source CSV library being actively developed Flatpack:正在积极开发的开源 CSV 库
  • CSVeed: Open-source and actively-maintained. CSVeed:开源并积极维护。

After the.csv file is created you can use aws sdk ( aws-java-sdk-s3 ) to upload the file.创建 .csv 文件后,您可以使用 aws sdk ( aws-java-sdk-s3 ) 上传文件。 Reference link for S3 file upload S3文件上传参考链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM