Import then Export without changing spaces and column widths

matt28

New Member
Joined
Jan 14, 2005
Messages
2
I have data in text form which I want to import into excel, re-sort on of the columns (Ascending or Descending order) and then export it back to text. The clolumn width should not change and no spaces should be generated or deleted, otherwise other applications will not be able to read my file. An example of my data -

ATOM 1 HT1 ARG 1 38.208 12.675 16.098 1.00 0.00 G5A
ATOM 2 HT2 ARG 1 37.062 13.111 14.922 1.00 0.00 G5A
ATOM 3 N ARG 1 37.494 13.382 15.829 1.00 45.73 G5A
ATOM 4 HT3 ARG 1 36.758 13.427 16.563 1.00 0.00 G5A
ATOM 5 CA ARG 1 38.127 14.684 15.695 1.00 60.03 G5A
ATOM 10 HE ARG 1 40.240 18.099 16.808 1.00 0.00 G5A
ATOM 50 HE21 GLN 4 36.442 11.675 8.997 1.00 0.00 G5A
ATOM 101 C VAL 9 27.179 20.374 9.433 1.00 12.10 G5A

Above data only appears as if the spaces are different in each line, but in fact they are the same. I need to import this into excel and re-sort it according to the 5th column (descending) and export it again without adding or deleting any spaces.
The field description are -
Position 1-6 should be column 1 (ATOM then two spaces).
Position 7-11 should be column 2 containing integers. (First line has 1 so it should have 4 spaces then 1).
Position 12 is a blank space always, so Column 3 is a blank column with 1 space width.
Position 13-16 has text+numbers (HT1 means one space followed by HT1)

And so on.

Can anyone help me how to create columns of fixed width while importing as well as exporting. I tried space delimited importing by positioning the separator lines exactly where I need, but the spaces are lost after import. I do not care much about import, but the export needs to be in the exact format. Thanks.

Matt
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Have you tried importing using fixed width rather than delimited?
 
Upvote 0
Re: Import then Export without changing spaces and column wi

Yes I did. It imports it but spaces such as the two spaces after the word ATOM are lost. The cell would only contain ATOM in it. Also a number such as 28.450 will get converted to 28.45 thus shifting everything in the row.

Maybe someone know of another program other than excel...
 
Upvote 0

Forum statistics

Threads
1,203,528
Messages
6,055,928
Members
444,835
Latest member
Jonaskr

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top