[prev in list] [next in list] [prev in thread] [next in thread]
List: python-list
Subject: Re: Reading by positions plain text files
From: MRAB <python () mrabarnett ! plus ! com>
Date: 2010-11-30 23:36:49
Message-ID: 4CF58A91.50100 () mrabarnett ! plus ! com
[Download RAW message or body]
On 30/11/2010 21:31, javivd wrote:
> Hi all,
>
> Sorry, newbie question:
>
> I have database in a plain text file (could be .txt or .dat, it's the
> same) that I need to read in python in order to do some data
> validation. In other files I read this kind of files with the split()
> method, reading line by line. But split() relies on a separator
> character (I think... all I know is that it's work OK).
>
> I have a case now in wich another file has been provided (besides the
> database) that tells me in wich column of the file is every variable,
> because there isn't any blank or tab character that separates the
> variables, they are stick together. This second file specify the
> variable name and his position:
>
>
> VARIABLE NAME POSITION (COLUMN) IN FILE
> var_name_1 123-123
> var_name_2 124-125
> var_name_3 126-126
> ..
> ..
> var_name_N 512-513 (last positions)
>
> How can I read this so each position in the file it's associated with
> each variable name?
>
It sounds like a similar problem to this:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/53ebbbb6f41bfff6/123422d510187dc3?show_docid=123422d510187dc3
--
http://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic