Insert a column in the beginning


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Insert a column in the beginning

Hi, I have been trying to see how i can insert a column in the beginning to my html table

This is how it looks

Code:
Name Age 
Sid     32   
John   33
Mary   34

I want to insert a column Job before Name column, so it looks like

Code:
Job      Name   Age 
IT        Sid       32   
Doctor John     33
Nurse   Mary    34

I tried with
HTML Code:
<thead><tr>Job</tr></thead>
<tr><td>IT</td></tr>
<tr><td>Doctor</td></tr>
<tr><td>Nurse</td></tr>
but the output looks
Code:
Job
IT
Doctor
Nurse
Name Age 
Sid     32   
John   33
Mary   34

# 2  
You will need to arrange it like <tr><td>column1</td><td>column2</td><td>column3</td></tr>

If you mean you want an automatic solution, what format do you have your input data in?
# 3  
Thanks for the reply, however this would insert one row and the different columns.

I have it as space delimited columns as the raw file
# 4  
Code:
<table>
  <tr>
    <th>Job</th>
    <th>Name</th> 
    <th>Age</th>
  </tr>
  <tr>
    <td>IT</td>
    <td>Sid</td>
    <td>32</td>
  </tr>
  <tr>
    <td>Doctor</td>
    <td>John</td>
    <td>33</td>
  </tr>
  <tr>
    <td>Nurse</td>
    <td>Mary</td>
    <td>34</td>
  </tr>
</table>

Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Insert text at the beginning of every even number line
bob123
i am trying to insert text at the beginning of every even number line with awk i can do it with odd number lines with this command awk 'NR%2{$0="some text "$0}1' filehow can i edit this command thanks... Shell Programming and Scripting
5
Shell Programming and Scripting
Insert output from a file to beginning of line with sed
diesel88
Hi I've been trying to search but couldn't quite get the answer I was looking for. I have a a file that's like this Time, 9/1/12 0:00, 1033 0:10, 1044 ... 23:50, 1050 How do I make it so the file will be like this? 9/1/12, 0:00, 1033 9/1/12, 0:10, 1044 ... 9/1/12, 23:50, 1050 I...... Shell Programming and Scripting
4
Shell Programming and Scripting
Insert at the beginning of odd lines
drbiloukos
Hello people, I am trying with sed to insert some text at the beginning of each odd line of a file but no luck. Can you please help. Awk is also suitable but I am not very familiar with it. Thank you in advance for any help.... Shell Programming and Scripting
7
Shell Programming and Scripting
Need to insert text(constant) at the beginning of file
jclanc8
I am very new to scripting and I know this request is simple but I am having no luck with it. I have a file a.dat with the following data in it. aa bb cc dd I need to run a script that will take each line of a.dat and put dsjc/ubin/ in front of each record, so the output looks like ...... Shell Programming and Scripting
2
Shell Programming and Scripting
Insert two strings at the beginning and at the end of each line of a file
Linux-fueled
Hi, excuse me for my poor english. My problem is that: I have a File i want to add to each line of that file two strings: one at the beginning of the line, one at the ending. string1="abcd" string2="efgh" i want $string1 content $string2 for each line. Is that possible?... Shell Programming and Scripting
3
Shell Programming and Scripting