Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6383619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:40:20+00:00 2026-05-25T02:40:20+00:00

This are the first three lines of my text file: Dist Mv CL Typ

  • 0

This are the first three lines of my text file:

  Dist    Mv  CL Typ  LTef  logg Age Mass  B-V    U-B    V-I    V-K    V   [Fe/H] l           b         Av   Mbol
  0.033 14.40  5 7.90 3.481  5.10  1 0.15  1.723  1.512  3.153  5.850 17.008  0.13   0.50000   0.50000  0.014 12.616
  0.033  7.40  5 6.50 3.637  4.62  7 0.71  1.178  0.984  1.302  2.835 10.047 -0.56   0.50000   0.50000  0.014  6.125
  0.052 11.70  5 7.40 3.529  4.94  2 0.31  1.541  1.167  2.394  4.565 15.393 -0.10   0.50000   0.50000  0.028 10.075

Assuming I have the right columns, how do I import this?

Bonus: is it possible/are there tools to create the schema from these kinds of files automatically?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:40:20+00:00Added an answer on May 25, 2026 at 2:40 am

    At lowest level you could just use COPY command (or \copy in psql if you don’t have access to superuser account, which COPY requires to load data from file). Unfortunately you have to create table structure at first (there is no built-in guess-by-header feature), but it looks straightforward to write one.

    Choose whaterer suitable datatype you need e.g. real for single precision floating-point (IEEE 754), double precision or numeric if you need arbitrary precision numbers:

    CREATE TABLE measurement
    (
        "Dist" double precision,
        "Mv" double precision,
        "CL" double precision,
        "Typ" double precision,
        "LTef" double precision,
        "logg" double precision,
        "Age" double precision,
        "Mass" double precision,
        "B-V" double precision,
        "U-B" double precision,
        "V-I" double precision,
        "V-K" double precision,
        "V" double precision,
        "[Fe/H]" double precision,
        "l" double precision,
        "b" double precision,
        "Av" double precision,
        "Mbol" double precision
    );
    

    Another thing is that your file contains multiple spaces between values, so it’s better to transform it into single-tab-delimited entries (there are plenty of tools to do this):

    $ sed 's/  */\t/g' import.csv
    Dist    Mv  CL  Typ LTef    logg    Age Mass    B-V U-B V-I V-K V   [Fe/H]  l   b   Av  Mbol
    0.033   14.40   5   7.90    3.481   5.10    1   0.15    1.723   1.512   3.153   5.850   17.008  0.13    0.50000 0.50000 0.014   12.616
    0.033   7.40    5   6.50    3.637   4.62    7   0.71    1.178   0.984   1.302   2.835   10.047  -0.56   0.50000 0.50000 0.014   6.125
    0.052   11.70   5   7.40    3.529   4.94    2   0.31    1.541   1.167   2.394   4.565   15.393  -0.10   0.50000 0.50000 0.028   10.075
    

    Finally you can import your file straight into Postgres database, for example:

    => \copy measurement FROM '/path/import.csv' (FORMAT csv, DELIMITER E'\t', HEADER 'true')
    => TABLE measurement;
     Dist  |  Mv  | CL | Typ | LTef  | logg | Age | Mass |  B-V  |  U-B  |  V-I  |  V-K  |   V    | [Fe/H] |  l  |  b  |  Av   |  Mbol  
    -------+------+----+-----+-------+------+-----+------+-------+-------+-------+-------+--------+--------+-----+-----+-------+--------
     0.033 | 14.4 |  5 | 7.9 | 3.481 |  5.1 |   1 | 0.15 | 1.723 | 1.512 | 3.153 |  5.85 | 17.008 |   0.13 | 0.5 | 0.5 | 0.014 | 12.616
     0.033 |  7.4 |  5 | 6.5 | 3.637 | 4.62 |   7 | 0.71 | 1.178 | 0.984 | 1.302 | 2.835 | 10.047 |  -0.56 | 0.5 | 0.5 | 0.014 |  6.125
     0.052 | 11.7 |  5 | 7.4 | 3.529 | 4.94 |   2 | 0.31 | 1.541 | 1.167 | 2.394 | 4.565 | 15.393 |   -0.1 | 0.5 | 0.5 | 0.028 | 10.075
    (3 rows)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Text File(First three lines are simple to read, next three lines starts with p)
I'm trying to get data from file. The file first has three lines of
My text file format is : This is first line. This is second line.
In a text file like this: First Name last name # secone name Address
I have this text file that contains approximately 22 000 lines, with each line
I need to create an output text file by deleting the first two lines
This is really a three-part question, but I've answered the first question myself: I'm
I'm designing a daemon that will continuously read lines from a single text file
Say I have the following style of lines in a text file: 12 34
I have a text file in this format: abc? cdfde nhj.cde' dfwe-df$sde..... How can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.