Skip to main content
edited tags
Link
Mr.Wizard
  • 275.2k
  • 34
  • 606
  • 1.5k
deleted 1 character in body
Source Link
mrz
  • 11.8k
  • 2
  • 28
  • 90

As an example I have a data list of dimension {10, 5}:

data=Get["http://pastebin.com/raw/AxGXqgAb"] {{15,0,0,69,250},{15,0,0,88,121},{15,0,0,107,248},{15,0,0,125,119}, {15,0,0,144,246},{15,0,0,163,117},{15,0,0,181,244},{15,0,0,200,115}, {15,0,0,219,242},{15,0,0,237,113}} 

I want to export the integers (0-255) right aligned into a text file with 10 rows and 5 columns (no curly braces) and each intergerinteger should occupy 3 spaces with a white space in between.

My code does not exactly what I want and looks relatively complicated.

formatted=Map[NumberForm[#,{3,0},NumberPadding->{" ","0"},NumberPoint->""]&,data,{2}] Export[StringJoin[imageDir,"\\timeStampBytes4.txt"],formatted,"Table"]; 

The output file contains:

 15 0 0 69 250 15 0 0 88 121 15 0 0 107 248 15 0 0 125 119 15 0 0 144 246 15 0 0 163 117 15 0 0 181 244 15 0 0 200 115 15 0 0 219 242 15 0 0 237 113 

What is the most straightforward solution for my problem?

As an example I have a data list of dimension {10, 5}:

data=Get["http://pastebin.com/raw/AxGXqgAb"] {{15,0,0,69,250},{15,0,0,88,121},{15,0,0,107,248},{15,0,0,125,119}, {15,0,0,144,246},{15,0,0,163,117},{15,0,0,181,244},{15,0,0,200,115}, {15,0,0,219,242},{15,0,0,237,113}} 

I want to export the integers (0-255) right aligned into a text file with 10 rows and 5 columns (no curly braces) and each interger should occupy 3 spaces with a white space in between.

My code does not exactly what I want and looks relatively complicated.

formatted=Map[NumberForm[#,{3,0},NumberPadding->{" ","0"},NumberPoint->""]&,data,{2}] Export[StringJoin[imageDir,"\\timeStampBytes4.txt"],formatted,"Table"]; 

The output file contains:

 15 0 0 69 250 15 0 0 88 121 15 0 0 107 248 15 0 0 125 119 15 0 0 144 246 15 0 0 163 117 15 0 0 181 244 15 0 0 200 115 15 0 0 219 242 15 0 0 237 113 

What is the most straightforward solution for my problem?

As an example I have a data list of dimension {10, 5}:

data=Get["http://pastebin.com/raw/AxGXqgAb"] {{15,0,0,69,250},{15,0,0,88,121},{15,0,0,107,248},{15,0,0,125,119}, {15,0,0,144,246},{15,0,0,163,117},{15,0,0,181,244},{15,0,0,200,115}, {15,0,0,219,242},{15,0,0,237,113}} 

I want to export the integers (0-255) right aligned into a text file with 10 rows and 5 columns (no curly braces) and each integer should occupy 3 spaces with a white space in between.

My code does not exactly what I want and looks relatively complicated.

formatted=Map[NumberForm[#,{3,0},NumberPadding->{" ","0"},NumberPoint->""]&,data,{2}] Export[StringJoin[imageDir,"\\timeStampBytes4.txt"],formatted,"Table"]; 

The output file contains:

 15 0 0 69 250 15 0 0 88 121 15 0 0 107 248 15 0 0 125 119 15 0 0 144 246 15 0 0 163 117 15 0 0 181 244 15 0 0 200 115 15 0 0 219 242 15 0 0 237 113 

What is the most straightforward solution for my problem?

Tweeted twitter.com/StackMma/status/835199571340951555
edited tags
Link
Mr.Wizard
  • 275.2k
  • 34
  • 606
  • 1.5k
Source Link
mrz
  • 11.8k
  • 2
  • 28
  • 90
Loading