i am trying to edit a csv file from:
Return(result="success" dev_id="0" time="2011-07-25 16:43:43" id="1" name="persons name" workcode="" status="1" card_src="from_check"
To:
"2011-07-25,16:43:43,1,persons name"
or:
VarDate VarTime VarID VarName
Printable View
i am trying to edit a csv file from:
Return(result="success" dev_id="0" time="2011-07-25 16:43:43" id="1" name="persons name" workcode="" status="1" card_src="from_check"
To:
"2011-07-25,16:43:43,1,persons name"
or:
VarDate VarTime VarID VarName
You'll have to be a bit more clear the from csv is not csv the to is.
If this is to be a function that has those variables and needs to write them as a csv then that is very simple.
If that is not what you are asking then please give more info.Code:OutputString=Var1 & "," & Var2 & "," .........
If you want to extract the actual data from a line like given you'd need a little parser to find the keywords like "result" and then extract the data which comes always in quotes.
Note, that I had to double all the quotes to put them into a variable. You would presumably read one line like that and have it already imn a variable.Code:Private Function Parse(ByVal Line As String, ByVal KeyWord As String) As String
Dim p%, p1%, p2%
p = InStr(Line, KeyWord + "=") 'find the keyword
If p Then 'if the keyword plus "=" exists
p1 = p + Len(KeyWord) + 2 'find starting position of data
p2 = InStr(p1, Line, """") 'find ending position of data
Parse = Mid$(Line, p1, p2 - p1) 'extract data
End If
End Function
Private Sub Command1_Click()
Dim MyLine$
MyLine = "Return(result=""success"" dev_id=""0"" time=""2011-07-25 16:43:43"" id=""1"" name=""persons name"" workcode="""" status=""1"" card_src=""from_check"""
Print Parse(MyLine, "result")
Print Parse(MyLine, "dev_id")
Print Parse(MyLine, "time")
End Sub
You call the Parse function for each keyword which then returns the data without anymore quotes.
Instead of Print the data you would possibly put them in variables like
VarResult = Parse(MyLine, "result")