LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   LinuxQuestions.org Member Intro (https://www.linuxquestions.org/questions/linuxquestions-org-member-intro-24/)
-   -   Unix amateur (https://www.linuxquestions.org/questions/linuxquestions-org-member-intro-24/unix-amateur-667721/)

jonnymorris 09-05-2008 04:42 AM

Unix amateur
 
Hi,

I'm one who has used unix and saw that it was good, but struggles with the more complex aspects of shell scripts, perl, etc. I've come here initially seeking help with some CSV file text manipulation that really needs to be automated. I imagine a line or two of cunning sed should do the trick, but have never used sed myself.

indienick 09-05-2008 07:46 AM

Using age-old UNIX tools like sed is all well and good, but I would personally recommend using Python as a general, everyday-use scripting tool. If you have a CSV, it's really something as simple as:
Code:

import sys

file_to_open = sys.argv[1]
f = open(file_to_open, 'r')

file_buffer = f.read()
file_buffer = file_buffer.split(',')

In that example, you will be given a list (file_buffer) of all of the values that was previously one, big, comma-separated block o' text.

My other reason for suggesting Python, is that it is super easy to learn, powerful as all-get-out, and what knowledge you learn in Python (the same could be said for Perl and sed, however) is portable to other systems (Linux, Mac OS X, Windows, etc.)

pixellany 09-05-2008 08:36 AM

Welcome to LQ!!
The tool depends on what you want to do, n'est-ce pas?

I suggest you start a new thread with a specific question. (Maybe you already did....;))


All times are GMT -5. The time now is 04:36 PM.