Flat file

7 views
Skip to first unread message

MikeE

unread,
Jan 1, 2018, 10:48:25 AM1/1/18
to TextWrangler Talk
Is there a code that will left justify all lines of data based on the header row per column?
I need to take an excel file and generate a column based flat file so all rows in 1st column are 30 characters all rows in 2nd are 25 etc.

Christopher Stone

unread,
Jan 2, 2018, 6:15:40 AM1/2/18
to TextWrangler-Talk
On 01/01/2018, at 09:03, MikeE <ymwi...@gmail.com> wrote:
Is there a code that will left justify all lines of data based on the header row per column? 
I need to take an excel file and generate a column based flat file so all rows in 1st column are 30 characters all rows in 2nd are 25 etc.


Hey Mike,

You need to provide more information.

How are you exporting from Excel — as tab-delimited or comma-delimited text?

Demonstrate real (or realistic) before and after examples of what you want.

Depending upon the data and how you want it formatted this task could be as simple as a single-line text-filter, or it could be quite complex.

Run this from TextWrangler or BBEdit (Run in the SheBang menu) to see how it's converted to a flat table.



#!/usr/bin/env bash

read -r -d '' myTabDelimitedData <<'EOF'

HEADER 1 HEADER 2 HEADER 3
Some field data R1C1 Some more field data R1C2 Even more field data R1C3
Some field data R2C1 Some more field data R2C2 Even more field data R2C3

EOF

echo "$myTabDelimitedData" | column -t -s $'\t'



By the way — the TextWrangler list is pretty much dead.

BBEdit-lite has taken the place of TextWrangler.

The full version of BBEdit becomes the “lite” version after the full functioning demo period is over, and it is more powerful than the last version of TextWrangler.

So — the only user-list that has real traffic these days is the BBEdit-Talk list.


--
Best Regards,
Chris

Reply all
Reply to author
Forward
0 new messages