genfromtxt but I need to search file first
Hi, I'm processing a bunch of text files with headers. The header is many lines long, may be 43 lines, may be 42, maybe something else. The last line of the header is always : ~ASCII section After this there are columns of data that I want to load via genfromtxt (mainly to strip leading spaces, and to load directly into an array). Thing is, genfromtxt already loops twice through each file, so adding a bit of code like this: infile = open("my_text.txt","r") text = infile.read() infile.close() means the file is read 3 times. Is there another way? I'm new to python. Ben.
Hi Ben, On Mon, Apr 11, 2011 at 8:52 AM, Ben Harrison <ben.harrison@liquidmesh.com>wrote:
Hi, I'm processing a bunch of text files with headers. The header is many lines long, may be 43 lines, may be 42, maybe something else. The last line of the header is always :
~ASCII section
By any changes is this a LAS file? Take a look here: http://mail.scipy.org/pipermail/numpy-discussion/2011-March/055563.html and at my response. I included a "quick and dirty" implementation of a LAS reader. (I have a nicer version in progress, but it will be a few days before I can finish it.) In the version attached to that email, I just use loadtxt() to read the data after the ~A line. Warren
After this there are columns of data that I want to load via genfromtxt (mainly to strip leading spaces, and to load directly into an array). Thing is, genfromtxt already loops twice through each file, so adding a bit of code like this:
infile = open("my_text.txt","r") text = infile.read() infile.close()
means the file is read 3 times.
Is there another way? I'm new to python.
Ben.
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
On 13/04/11 00:25, Warren Weckesser wrote:
By any changes is this a LAS file? Take a look here: http://mail.scipy.org/pipermail/numpy-discussion/2011-March/055563.html and at my response. I included a "quick and dirty" implementation of a LAS reader. (I have a nicer version in progress, but it will be a few days before I can finish it.) In the version attached to that email, I just use loadtxt() to read the data after the ~A line.
Warren
Yes it is a LAS file, they are pesky things. I'll try your script, or steal methods from it! Will you be publishing your nicer script anywhere in particular? Could you let me know somehow when you have? Thanks, Ben.
On Tue, Apr 12, 2011 at 10:54 PM, Ben Harrison <ben.harrison@liquidmesh.com>wrote:
On 13/04/11 00:25, Warren Weckesser wrote:
By any changes is this a LAS file? Take a look here: http://mail.scipy.org/pipermail/numpy-discussion/2011-March/055563.html and at my response. I included a "quick and dirty" implementation of a LAS reader. (I have a nicer version in progress, but it will be a few days before I can finish it.) In the version attached to that email, I just use loadtxt() to read the data after the ~A line.
Warren
Yes it is a LAS file, they are pesky things. I'll try your script, or steal methods from it!
Will you be publishing your nicer script anywhere in particular? Could you let me know somehow when you have?
The "Input Output" section of the SciPy Cookbook ( http://www.scipy.org/Cookbook) looks like as good a place as any. I'll create a page for it there once I've clean up a few things. Warren
Thanks, Ben.
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
On Thu, Apr 14, 2011 at 5:00 PM, Warren Weckesser < warren.weckesser@enthought.com> wrote:
On Tue, Apr 12, 2011 at 10:54 PM, Ben Harrison < ben.harrison@liquidmesh.com> wrote:
On 13/04/11 00:25, Warren Weckesser wrote:
By any changes is this a LAS file? Take a look here: http://mail.scipy.org/pipermail/numpy-discussion/2011-March/055563.html and at my response. I included a "quick and dirty" implementation of a LAS reader. (I have a nicer version in progress, but it will be a few days before I can finish it.) In the version attached to that email, I just use loadtxt() to read the data after the ~A line.
Warren
Yes it is a LAS file, they are pesky things. I'll try your script, or steal methods from it!
Will you be publishing your nicer script anywhere in particular? Could you let me know somehow when you have?
The "Input Output" section of the SciPy Cookbook ( http://www.scipy.org/Cookbook) looks like as good a place as any. I'll create a page for it there once I've clean up a few things.
A LAS reader is now here: http://www.scipy.org/Cookbook/LASReader Warren
participants (2)
-
Ben Harrison -
Warren Weckesser