I need to create a simple program/utility to parse a txt file (deleting blank rows, concatenating lines, etc) that runs in Windows XP and can be called from a Windows command line. What programming language/environment best fits this type of application?
Thanks, I hope I'm no开发者_JS百科t being vague.
perl was designed from the ground-up for text processing
I would recommend Python.
Perl is my first and last one too.... i think it was made from scratch for something like this.
For a zero-install option, albeit a bit fiddley, you could use good ole Batch Files. Here is an awesome resource for this
Perl? Python? C#?
Really, any will do.
perl or python may work well for you.
If it's a very simple problem, you may wish to take a look at sed or awk.
First I'd use a scripting language, because those are usually easier/faster to get used with. And they are flexible and you don't need to compile things after each change, you can modify the code directly and just run it.
Secondly I wouldn't use a general purpose language, like C# or Python. While they will do great, they are really not the right tool for the job. They have lots of APIs and lots of choices to choose from. They are also tied to a runtime/fx, that needs to be deployed to the target machine.
Consider a "parsing" kind of language like Perl. Or you may want to use something like PowerShell. But I think Perl will do just great.
As others have mentioned, Perl or Python are good options, but if you don't want to install anything else, you can use JavaSript with Windows Scripting Host, which is far easier than C/C++ or Bash Scripting (other options that don't require additional software).
I'd say Gawk though I don't know if anyone uses it under Windows. (G)awks basic syntax is even easier to learn than Perl (you can learn most of it in a day), especially if you know any C-like programming language.
精彩评论