Re: How to insert data from a text file

From: Sean Davis <sdavis2(at)mail(dot)nih(dot)gov>
To: Mike <1100100(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: How to insert data from a text file
Date: 2009-06-18 18:04:31
Message-ID: 264855a00906181104g9d6fc42q34112a89fe3399f6@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Thu, Jun 18, 2009 at 1:51 PM, Mike <1100100(at)gmail(dot)com> wrote:

> Background:
>
> Thousands of folders and files filled with client data on the linux
> samba server.
> Searching for data is difficult due to ever-changing directory
> structures and naming schemes.
>
> Example (exaggerating to make a point):
>
> /air/water/vegetable/animal/broccoli/potato/crabby_client.doc
> /animal/broccoli/air/vegetable/poise_and_honor.pdf
>
> It goes on for about 650,000 files
>
> I used the following command to gather all file and directory names.
> "/abc" is the main directory on the linux samba server where all
> company data is located:
>
> root(at)acme:/# ls -Ralh /abc > /home/mike/file_output.txt
>
> file_output.txt is 33 megs. and lists approximately 650,000 file names
> and their directory paths.
>
> I want to pull all the file name info. and directory path info. from
> "file_output.txt" and place each file name into a postgresql database
> along with the related file location information.
> The ultimate goal is to be able to make an alpha-numeric query and be
> presented with matching file names and their location on the samba
> server.
>
> How do I pull the data from "file_output.txt" and place it into the
> postgres database?
>
> Any guidance and pointed RTFM declarations greatly appreciated.
>

With 650k lines, you can use python, perl, java, etc. to insert the records;
pick you language of choice. Alternatively, you can use the psql client and
its \copy command.

Just an aside, but on linux, have you looked into using either the find
command or locate, or even google desktop?

Sean

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Mike 2009-06-18 19:05:59 Re: How to insert data from a text file
Previous Message Mike 2009-06-18 17:51:39 How to insert data from a text file