peliosis Posted February 28, 2006 Share Posted February 28, 2006 I have some pointcloud data from custom 3d scanner in a text file. I need to import it into houdini as geo, but there are a few things to do: -Change all colons to spaces -Add "1" at the end of ech line (homogenous coords?) -Count the nr of lines and put it in "points:..." -Replace head and tail of the file Perhaps some other also but marginal. Because there are 370 000 of points / lines in the file it takes days in wordpad/jedit/crimson editor to just add "1". I think of learning some scripting language and chose python, since it looks the easiest and the most versatile. I work under linux, for a year now and would like to learn one language firmly to fill most of my needs. But It's only one day since I started learning it I have some experience with jscript and vbscript with xsi but nothing externally. I search for the easiest method of such simple file convertion. Do you think python is the right choice or perhaps should I stick to bash scripting or perhaps there is yet easier way to attack my problem? Quote Link to comment Share on other sites More sharing options...
sibarrick Posted February 28, 2006 Share Posted February 28, 2006 Python is my choice. Search for help on the open and write methods. file = open("myFile", 'r').readlines() this reads a file in bit busy at the moment hopefully someone else can fill in some more, python is good at this stuff.... later Quote Link to comment Share on other sites More sharing options...
peliosis Posted February 28, 2006 Author Share Posted February 28, 2006 Thanks Simon, I read all file object reference in the documentation and tutorial before posting this. Not that I understand how to use it all from where I stand . I have some troubles in cycling the lines for line in f: f.write('1') adds one "1" at the end of the file...probably not surprisingly. I know it's only a matter of time for me to get there. Unfortunatly learning python is doomed to be my overnight hobby so I have limited hour pack and falling eyelids as my classmates. I'd like only to know if python is a good language to start. Of course if you'd find a sec and write something to correct me I'd be very grateful. I really appreciate your help and time you take to answer all of us greenhorns, that motivates me to work harder. Quote Link to comment Share on other sites More sharing options...
crunch Posted February 28, 2006 Share Posted February 28, 2006 I have some pointcloud data from custom 3d scanner in a text file.I need to import it into houdini as geo, but there are a few things to do: -Change all colons to spaces -Add "1" at the end of ech line (homogenous coords?) -Count the nr of lines and put it in "points:..." -Replace head and tail of the file Perhaps some other also but marginal. Because there are 370 000 of points / lines in the file it takes days in wordpad/jedit/crimson editor to just add "1". I think of learning some scripting language and chose python, since it looks the easiest and the most versatile. I work under linux, for a year now and would like to learn one language firmly to fill most of my needs. But It's only one day since I started learning it I have some experience with jscript and vbscript with xsi but nothing externally. I search for the easiest method of such simple file convertion. Do you think python is the right choice or perhaps should I stick to bash scripting or perhaps there is yet easier way to attack my problem? 25178[/snapback] Use a real editor :-) In Vim: :1,$s/:/ /g will replace all : with a space. :1,$s/$/ 1 will add a 1 to the end of all the lines :!wc -l % will count your lines for you Then, it's a matter of adding the appropriate header/trailer. Of course, you could do it with python too. And if you had a lot of files to convert, python/perl/php would probably be a better route. Quote Link to comment Share on other sites More sharing options...
peliosis Posted February 28, 2006 Author Share Posted February 28, 2006 Ah that vim thing, I'm still very stubborn because it's so freakin' odd! I'd better get to like it, once while repairing the system, my favourite pico was just not there . Thanks, I'll check how it processes my 372 000 of lines. I'll need both python and vim anyway. Quote Link to comment Share on other sites More sharing options...
Mcronin Posted February 28, 2006 Share Posted February 28, 2006 Thanks, I'll check how it processes my 372 000 of lines. 25217[/snapback] My guess is very slowly. I just wrote a a script in perl script similar to what you are trying to do, for work. It takes about 5 full minutes process 100,000 lines. I expect VIM will take quite a bit longer than that to process ~400,000 lines. Quote Link to comment Share on other sites More sharing options...
peliosis Posted March 1, 2006 Author Share Posted March 1, 2006 My guess is very slowly. I just wrote a a script in perl script similar to what you are trying to do, for work. It takes about 5 full minutes process 100,000 lines. I expect VIM will take quite a bit longer than that to process ~400,000 lines. 25222[/snapback] I hope "quite a bit" will still be shorter than 2 days in windows editors mentioned It took some furious amount of time and was slowing progressively when the line nr advanced. Horrible. Quote Link to comment Share on other sites More sharing options...
lisux Posted March 1, 2006 Share Posted March 1, 2006 I hope "quite a bit" will still be shorter than 2 days in windows editors mentioned It took some furious amount of time and was slowing progressively when the line nr advanced. Horrible. 25223[/snapback] I am agree with Mcronin, a perl or python script will do the job faster. For this situation i would use sed. It is an inline editor and is very, very faster doing string substitution, and the syntax is very similar to Perl. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.