fileparsing

Parsing a File Format

I'm working with Quickbook's IIF file format and I need to write a parser to read and write IIF files and I'm running into some issues reading the files. The files are simple, they're tab deliminated. Every line is either a table definition or a row. Definitions begin with'!' and the table name, and rows begin with just the table name. ...

What is the best way to read a text file two lines at a time in Java?

BufferedReader in; String line; while ((line = in.readLine() != null) { processor.doStuffWith(line); } This is how I would process a file line-by-line. In this case, however, I want to send two lines of text to the processor in every iteration. (The text file I'm processing essentially stores one record on two lines, so I'm sendin...

Generating data structures by parsing plain text files

I wrote a file parser for a game I'm writing to make it easy for myself to change various aspects of the game (things like the character/stage/collision data). For example, I might have a character class like this: class Character { public: int x, y; // Character's location Character* teammate; } I set up my parser to read in ...

Simple data storing in Python

I'm looking for a simple solution using Python to store data as a flat file, such that each line is a string representation of an array that can be easily parsed. I'm sure python has library for doing such a task easily but so far all the approaches I have found seemed like it would have been sloppy to get it to work and I'm sure there ...

File Parsing in C#

I am building a game in Visual Studio 2008 and in order to build levels, i will have two types of files (more than that actually but these two are the only ones important to my question) i need to parse. One will dictate the contents of a level and will look something like this: LevelName = "Sample Level" Object1Type = "CustomObject" ...

What language is to binary, as Perl is to text?

I am looking for a scripting (or higher level programming) language (or e.g. modules for Python or similar languages) for effortlessly analyzing and manipulating binary data in files (e.g. core dumps), much like Perl allows manipulating text files very smoothly. Things I want to do include presenting arbitrary chunks of the data in vari...

Cleanest Perl parser for Makefile-like continuation lines

A perl script I'm writing needs to parse a file that has continuation lines like a Makefile. i.e. lines that begin with whitespace are part of the previous line. I wrote the code below but don't feel like it is very clean or perl-ish (heck, it doesn't even use "redo"!) There are many edge cases: EOF at odd places, single-line files, f...

Script to Parse and Change Numbers

I am working with numbers a lot when editing a particular type of file, and it's mostly tedious work. The file has a format like this: damagebase = 8.834 "abc_foo.odf" 3.77 "def_bar.odf" 3.77 "ghi_baz.odf" 3.77 "jkl_blah.odf" 4.05 ... What would you recommend for writing a script that parses this and lets me progra...

Please help me with this program to parse a file into an XML file.

To parse an input text file and generate a) an XML file and b) an SVG (also XML) file. The input text file (input.txt) contains the description of a number of produce distribution centers and storage centers around the country. Each line describes either a single distribution center (dcenter) or a storage center, each with a number of p...

What is the best file parsing solution for converting files?

I am looking for the best solution for custom file parsing for our enterprise import routines. I want to basically change one file format into a standard file format and have one routine that imports that data into the database. I need to be able to create custom scripts for each client since its difficult to get the customer to comply w...

Parsing File details for Windows FTP Server

Hi, I am trying to connect to FTP server through the c# code and I am getting the list of Files and directories. And that I am saving in a ArrayList(with all attributes). I can find the FTP Server type through the SYS ftp command. I have a regular expression for UNIX based files to parse the file\directories attributes. But I have no exp...

Print a string that contains a certain pattern in Java

I am trying to find a regular expression within a line of a .csv file, so I can eventually save all the matches to another file, and lose all the other junk. So a line in my file might look like: MachineName,User,IP,VariableData,Location The VariableData is what I want to match, and if there's a match, print the line. I am using a patt...

Given a trace of packets, how would you group them into flows?

I've tried it these ways so far: 1) Make a hash with the source IP/port and destination IP/port as keys. Each position in the hash is a list of packets. The hash is then saved in a file, with each flow separated by some special characters/line. Problem: Not enough memory for large traces. 2) Make a hash with the same key as above, but ...

In Ruby Compare 2 lines in a log file which BOTH contain the SAME "WORD" but ONLY print out the line that was written LASTLY

here are sample lines Apr 9 11:53:26 skip [2244]: [2244] ab-cd-ef:cc [INFO] A recoverable error has occurred some other log lines .. .... Apr 9 12:53:26 skip [2244]: [2244] ab-cd-ef:cc [INFO] A recoverable error has occurred now the LATEST line would have to be one with the latest Date String, and THAT is the one that needs to be pr...

CFF Font File parsing

Hi, I am developing an application which requires me to do fetch the glyph id from the CFF stream either through a character code or through a glyph name. This is a raw CFF stream and is not embedded inside an OTF File. I need to parse the CFF stream to fetch the charset and encoding information. Using that, how do I get to glyph indices...

Handling File Contents Before Writing to Disc C#

So I have decrypted a file and am left with a byte array containing this (Uni-encoded): Content-Type: text/plain; name="testfile.txt" Content-Transfer-Encoding: binary Content-Disposition: attachment; filename="testfile.txt" My super secret message. Where "My super secret message." is the contents of the file, which could be ...

File processing in java

I have a file of size 2GB which has student records in it. I need to find students based on certain attributes in each record and create a new file with results. The order of the filtered students should be same as in the original file. What's the efficient & fastest way of doing this using Java IO API and threads without having memory ...

Generate binary file with given structure

I have a device witch use binary format style config, and i have to generate that files on-the-fly. File structure must consist of a number of configuration settings (1 per parameter) each of the form: Type Length Value where: Type: is a single-octet identifier which defines the parameter Length: is a single octet containing the l...