使用正则表达式从逗号分隔的csv捕获项目

时间:2017-12-07 02:08:24

标签: python regex

我正在尝试捕获starttimestoptimetripdurationfrom_station_idto_station_idgenderbirthyear来自以下数据。

trip_id,starttime,stoptime,bikeid,tripduration,from_station_name,to_station_name,from_station_id,to_station_id,usertype,gender,birthyear
431,10/13/2014 10:31,10/13/2014 10:48,SEA00298,985.935,2nd Ave & Spring St,Occidental Park / Occidental Ave S & S Washington St,CBD-06,PS-04,Member,Male,1960

我只是想让正则表达式从代码中识别这些项目。

1 个答案:

答案 0 :(得分:0)

如果你真的真的想要一个正则表达式,那么你可以使用以下一个:

([^,]*)(?=,|$)

<强>试验:

enter image description here

祝你好运,如果你需要解释,请告诉我。