0

I have a .csv file with four columns, lacking the headline. I have to insert a new line with the names for each columns. How can I do this?

2 Answers 2

1

No need to use awk for this:

(
    printf "label1 label2 label3 label4\n"
    cat file.csv
) > file1.csv
Sign up to request clarification or add additional context in comments.

Comments

0

I'm sure there are more sophisticated approaches, but a very blunt way is to create a header file with:

printf "SNP BP A1 TEST NMISS OR SE L95 U95 STAT P\n" > header

(use names of your column separated by space) and then do

cat header myfile.txt > myfile.withheader.txt

provided that your myfile.txt is also space-separated.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.