gpt4 book ai didi

java - 从 csv 文件的 1 列中删除前导零

转载 作者:行者123 更新时间:2023-12-01 06:13:37 24 4
gpt4 key购买 nike

我正在寻找一种快速方法来删除 CSV 文件第一列中的前导零,以便另一个程序可以很好地使用它。如果可能的话,最好将其从逗号分隔转换为制表符分隔,但这可能必须是一个单独的问题。

以下是标题名称(只需从学生 ID 中去掉前导 (2) 个零):

"Student ID","School Name","Contact Relation","Contact First Name","Contact Last Name","Salutation"," Home Phone Number","Address Line 1","Address Line 2","City","State","Zip","Zip + 4","Work Phone","Cell Phone","Pager","Residential Status","Custodial Status"

这里有一些示例数据,用于查看其格式:

"004000031","Local High School","Mother","FirstName","LastName","","555-5557773","555 Old Midlothian Tpke","Lot77","Richmond","VA","23222","","","","","","Y"

最佳答案

这一行应该做到这一点:

String[] tokens = String.join("\t", csv.replaceFirst("^\"0*", "\"").split(","));

关于java - 从 csv 文件的 1 列中删除前导零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29496019/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com