Using File How To Parse This CSV Type?
Jun 6, 2009Using FileHelpers; how to parse this CSV type
View 1 RepliesUsing FileHelpers; how to parse this CSV type
View 1 RepliesHaving a few problems trying to parse a CSV in the following format using the FileHelpers library. It's confusing me slightly because the field delimiter appears to be a space, but the fields themselves are sometimes quoted with quotation marks, and other times by square brackets. I'm trying to produce a RecordClass capable of parsing this.Here's a sample from the CSV:
xxx.xxx.xxx.xxx - - [14/Jun/2008:18:04:17 +0000] "GET http://www.some_url.com HTTP/1.1" 200 73662339 "-" "iTunes/7.6.2 (Macintosh; N; Intel)"
It's an extract from an HTTP log we receive from one of our bandwidth providers.
I'm trying to import XML duration data into my app and store it as a Timespan.An XElement named 'Q' has a child element 'Timer' of type xs:duration. To extract the value I use the code below:
Dim Timer As Timespan
If Not TimeSpan.TryParse(Q.<Timer>.Value, Timer) Then Timer = Nothing
[code].....
I have some JSON data that looks like this[code]...
I get one root object with key "data", and value another object with 2 children, with keys "name" and "id", and the appropriate values one might expect. But when I try to cast that object to my UserData type, it returns Nothing. I had this code working at some point, but now that I am returning to it and attempting to use it again, it seems some code rot has set in and it has stopped working.
I have an vCard application that needs to read vCard Data, and have found a RegularExpression which gets the FieldName, Encoding and FieldValue from the file, here it is below:
^(?<FIELDNAME>[w-]{1,})(?:(?:;?)(?:ENCODING=(?<ENC>[^:;]*)|CHARSET=(?<CHARSET>[^:;]*))){0,2}:(?:(?<CONTENT>(?:[^
]*=
){1,}[^
]*)|(?<CONTENT>[^
]*))
This Regular Expression Reads these kind of values fine:
ORG:Company
FN;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:RoguePlanetoid
However I want it to read these values also
TEL;WORK;VOICE:0200 0000000
Without skipping them. How can I modify the RegularExpression so TEL;WORK;VOICE ends up as part of the "FIELDNAME" and 0200 0000000 is part of the "CONTENT".I am unfamiliar with complex RegularExpressions and cannot figure out how to modify it, there is a regular expression that gets these:
^(?:TEL)([^:]*):(?<TEL>[^
]*)
However it only gets the FieldName as "TEL" and I need the whole value for this so I can tell the numbers apart in my application.If possible the Regular Expression would read the WORK and VOICE elements also like the CHARSET and ENCODING in the current regular expression, so they can treated like an Attribute and Type for example, however anything which allows the Regular Expression to read the whole TEL;WORK;VOICE as the FIELDNAME will be fine.
Edit
^(?<FIELDNAME>[^:]{1,})(?:(?:;?)(?:ENCODING=(?<ENC>[^:;]*)|CHARSET=(?<CHARSET>[^:;]*))){0,2}:(?:(?<CONTENT>(?:[^
]*=
){1,}[^
]*)|(?<CONTENT>[^
]*))
Reads up to the first Colon which covers the Whole FieldName, however it would be nice to store each SemiColon Element in a seperate item such as ATTRIBUTE or TYPE.
modify RegularExpression to Parse vCard/vCalendar to allow a particular field type?
View 5 RepliesI need to parse some text to extract the name/path of an image file inside an X file. The part of the file looks something like this:
TextureFilename {
"C:\\Users\\USER\\Documents\\Map\\Textures\\Grass01.dds";
}
[code].....
# TAG NAME = is saved to a file using the code below but when I load that same file back into a RichTextbox Control using additional code below, I get inconsistent results as I try to parse the text. Has anyone else had this problem?'Save the contents of the RichTextBox into the file.richTextBox.SaveFile(saveFile1.FileName, RichTextBoxStreamType.RichText);'Retrieve contents of File into RichTextBox control Dim logData As String
logData = System.IO.File.ReadAllText(path + "\" + filenname);
How can I parse a text file and extract the data to excel file. The text file is in the following format
CustomerInformation
Tim Alen
596 George Town
[Code].....
I just want to parse simple expressions like IIF(FVAL(PFC) = TRUE, (IIF((ORGVAL(BAS, "2012/12/31") + ORGVAL(DA)) < 6500, (FVAL(BAS) + FVAL(DA)) * 12%, 780)), 0)`After parsing this I should be able to know what functions contains what parameters.
[Code]...
I'm stuck with .Net Framework 2.0, so no Linq or lambda expression goodies for me. Also I want to include the code in my custom library and not just reference it. Can anyone point me to some good library or code.
I just need to parse and not evaluate the expression and find what tokens are in use. After finding the tokens I need to change the expression string before parsing, like if the function ORGVAL is used then the parameter passed has has to be prefixed by an underscore. Like ORGVAL(BAS) will transform to ORGVAL(_BAS). Some functions can have tow parameters like ORGVAL(BAS, "2012/12/31") and this will transform to ORGVAL(_BAS, "2012/12/31")
NOTE: IF THERE ARE OTHER WAYS OF DOING IT PLEASE LET ME KNOW. I WOULD LOVE TO AVOID A PARSER AND LEXER.
I have a script that parses the value from between two parenthesis -now i need to modify the script to exctract the name after the second underscore and before the third underscore...is there a way to do that?...This is a vb script task in side of a ssis package
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
[code]....
I have an app that the user selects information and it writes to an XML file. The user can increase and decrease the information in the XML file so it is dynamic. The other app reads the xml file and uses it to complete tasks. Since the XML is dynamic my code needs to account for that. Right now I have only allowed the XML to have up to four values in a certain node, I would like to allow more but I will need to increase the Select Case function.[code]
View 8 RepliesI have this following XML File. I would like to get the values of first Hsp_qseq, Hsp_hseq and Hsp_midline under tag HSP in VB.NET from the file out.xml
<?xml version="1.0"?>
<!DOCTYPE BlastOutput PUBLIC "-//NCBI//NCBI BlastOutput/EN" "NCBI_BlastOutput.dtd">
<BlastOutput>
[code].....
How can I parse XML that I don't have a file for?
I get the (dynamic) XML from an HTTP request, but all the XML classes I looked don't seem to be able to accept a string variable rather than a file.
I tried using XPath like this, but it just hangs.
Code:
Dim document as XPathDocument = new XPathDocument("http://www.myurl.com")
I occasionally have to search a very large text file as a troubleshooting step. The file is continuous text (with spaces between much of the text) but almost everything is date/time stamped. The text is actually messages between two machines so I'd like to insert a line break after every message so that I can follow the protocol exchange. Thre are also a few key words that I'd like to again, separate with a line break.
View 1 RepliesI occasionally have to search a very large text file as a troubleshooting step. The file is continuous text (with spaces between much of the text) but almost everything is date/time stamped. The text is actually messages between two machines so I'd like to insert a line break after every message so that I can follow the protocol exchange. Thre are also a few key words that I'd like to again, separate with a line break
View 2 RepliesI want to parse a LOCAL html file and I don't know how. For example i have a file "c:MyFile.html" which contains:
<html>
<a> My String </a>
</html>
I'm working on a project and am kind of new to parsing files as well as listviews. I am trying to parse a file. Here is an example of what I need to parse.
a:b:c:d:e:f:g
a:b:c:d:e:f:g
a:b:c:d:e:f:g
Each entity needs to be stored in it's respective column in the listview. So therefore I need to read the file in line by line.
So, I'm writing an application to extract data from an excel sheet and output it nicely in a text boss, sounds simple to me at least. But for some reason ( and it was working fine earlier, don't recall changing anything.) The file is not being parsed before being stored into the array. And since it's not parsed, it's not seeing it in the array as I don't have it set up to look for a substring.[code]...
View 1 RepliesI am trying to pull out a row of comma seperated fields from a text file. I have a combo box which pulls a product number, and what I want it to do it after you select the item in the combo box it will search through the text file and pull everything in that row?
View 1 RepliesI am using VB.NET 2005 (if that matters).I need to parse a text (log) file in which to process lines like:
Program Up at: Tue Jun 24 11:32:53.656 2008 - TerrificProgram.exe
<some lines here which I ignore>
0.00:24:16 - Emergency Stop!
<more lines to ignore>
Program Down at: Thu May 29 22:22:56.000 2008
where the 0.0:24:16 is the offset in TimeSpan format (d.hh:mm:ss) relative to the 'Program Up at" datetime.The 'Program Up at: <date/time>' line I successfully detect (in another function which works) and as a result a set a Boolean flag that I am in a valid <Up> - <Down> sequence and I also set a Start-up DateTime var to which to add the offsets later.
The task is to convert the TimeSpan at the beginning of the 'Emergency stop' line to a regular DateTime expression and to write the converted line to another log-file.Simple, isn't it?The function I use for the above purpose is:
Private Function IsTimeSpan(ByRef InputLine As String, ByVal ProgStart As Boolean, ByVal DTofProgStart As DateTime, ByRef NewDateTime As DateTime)
Dim iLine As String = InputLine
Dim Index As Integer = iLine.IndexOf(" ")
[code]....
What I am doing is I pass each line ('InputLine' parameter) from the original log-file to the function together with the 'in <up>-<down>' flag ('ProgStart' parameter'), the start ot program DateTime (in the 'DTofProgStart') and I want the NewDate to hold the real datetime of Emergency event occurence (not its offset).
What happens is that I successfully detect the lines of interest but the NewDateTime is not updated (though 'ts' is in the correct format and the assignment 'NewDateTime = DTofProgStart' correctly assigns the passed value).Another curious thing is that the line
InputLine.Replace(testStr, NewDateTime.ToString("MMM dd HH':'mm':'ss yyyy"))
does not change the original TimeSpan beginning of 'InputLine' with the regular DateTime (though not updated) in 'NewDateTime'.Why?
I am trying to parse a date from a file name.The File's Name is like "FILE_NAME.20110831..No extension or antything.[code]
View 3 RepliesI am working on a .NET 3.5 Windows Forms application that will interact with a REST Web Service which outputs an XML file such as the following:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<Response Status="OK">
<Item Name="NumberZones">2</Item>
[code].....
Example Data Link - Sorry, wouldnt format correctly when pasted.
1.
Dec 01, 2011
06:00:00 AM
Dec 01, 2011
[code].....
Output something like
12/1/2011 6:00:00 AM 12/1/2011 7:05:00 AM 65 65 2.11
I was wondering if anyone had a better(faster) way to parse a Tab delimited file in VB.net. need to read a file into an SQL table and the file contains about 300,000+ rows
Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(FilePath)
MyReader.TextFieldType = FileIO.FieldType.Delimited
MyReader.SetDelimiters(vbTab)
[code].....
I am editing BINary file and i need to parse some values from it without corruption of file, unfortunately I was try everything, but I dont know how to parse it on the byte level. I know how to read, write, search bytes from files but not how to parse it.
View 1 RepliesI was wondering if anyone had a better(faster) way to parse a Tab delimited file in VB.net. I need to read a file into an SQL table and the file contains about 300,000+ rows. Takes quiet a while. at the moment i have the below [Code].
View 6 RepliesI am trying to extract inforamtion from a website, I was able to get to the point of extract HTML to TXT. not I want to parse from this line TOTAL 3723
View 1 RepliesI have to parse through a text file that is growing and currently is about 30MB, but it takes a long time for the stream reader to load it before It can loop through the lines. Is there a faster method other than the streamreader?
View 2 RepliesWhat I'm trying to do is parse a CSV file that has column headers, and map those headers - ideally to a class.The tricky part is that I need to be able to support various mappings because it will be interacting with different systems that give the headers different names. Additionally, being able to combine fields would be extremely helpful.
Fortunately, the CSV will always be correctly formatted with all fields encapsulated in double quotes.
[Code]...