VC 一部分列含有雙引號的CSV資料分割

2021-04-18 10:06:46 字數 826 閱讀 8839

其實這個我一直在想最好還是用正規表示式實現,但發現效率有些不理想,而且這種情況下流程也複雜了

csv每行記錄中有時會有乙個單元段資料中出現雙引號的情況,

針對這種情況寫乙個函式,**如下:

void getcsvrecordcolumnsdata(cstring record, clist& retlist)

clistlist;

retlist.removeall();

cstring str =record;

int len = str.getlength();

int ipos = str.find(","), istart = 0, offset = 0, findstartindex = 0;

while (ipos != -1)

list.addtail(str.mid(istart, ipos - istart));

istart = ipos + 1;

ipos = str.find(",", istart);

if (istart <= len)

list.addtail(str.mid(istart));

position pos = list.getheadposition();

cstring prewords, curword;

offset = 0;

while(pos != null)else if (curword.mid(0,1) == "/"")elseelseelse{

retlist.addtail(curword);

++findstartindex;

有其他方法的朋友分享出來吧。

今天看懂了uCOS II H的一部分 列表如下

os ext int8u ospriocur priority of current task os ext int8u ospriohighrdy priority of highest priority task os ext int8u osrdygrp ready list group os...

青鳥影院 的最後一部分

using system using system.collections.generic using system.linq using system.text using system.threading.tasks namespace 青鳥影院 public scheduleitem movi...

Python Django 取url的一部分

在views.py中獲取urls.py中的正規表示式中的乙個引數 中的可變的匹配引數 在urls中給引數加上分組,在views中獲取引數 urls.py url r article d d view.aaa d匹配數字 匹配個數 外面套上小括號成為分組 views.py def aaa reques...