Mathematica Mathematica: create b-file for OEIS

  • Thread starter Thread starter jackmell
  • Start date Start date
  • Tags Tags
    Mathematica
Click For Summary
To create a b-file for the OEIS using Mathematica, the user initially faced issues with the default export format, which included brackets. The correct approach involves using the Export function with "Table" to format the data in a column but still required additional adjustments. The user ultimately resolved the formatting issue by converting the array elements to strings, ensuring a space between columns and adding a carriage return at the end of the file. The final code successfully exports the data in the required format for OEIS submission. This solution highlights the importance of adhering to specific formatting guidelines when submitting sequences.
jackmell
Messages
1,806
Reaction score
54
I'd like to save a Mathematica array as a "b-file" so that I can upload it to the on-line encyclopedia of integer sequences. Here's a short version of my array:

bData={{2,1},{3,1},{4,1},{5,2},{6,1},{7,2},{8,6},{9,2},{10,2},{11,4}}

and the b-file format would be:

2,1
3,1
4,1
5,2
6,1
7,2
8,6
9,2
10,2
11,4

However if I just put it to disk via:

bData>>"C://Abstract Algebra//b12345.txt"

Mathematica will just put it in array form with the brackets. Could someone help me put this data in the correct format for OEIS?

Ok thanks,
Jack
Edit:

This is close:

Export["C://Abstract Algebra//b23333.txt",myData,"List"]

that's all in a column but still has brackets around each row of data.

This is it guys:

Export["C://Abstract Algebra//b23333.txt",myData,"Table"]

(sorry I can't delete the thread)
 
Last edited:
Physics news on Phys.org
Just want to update this: OEIS requires a strict format for the b-file: one space between first column and second column and a CR at the end of the file. My solution was just to convert it all to strings and manually format it. Here's the code I used:

Code:
myData = {};

For[i = 1, i <= Length[theList], i++,

myString = StringJoin[ToString[theList[[i,1]]], " ", ToString[theList[[i,2]]]];

myData = Append[myData, myString]; ];

myData = Append[myData, ""];

Export["C://myDir//b258615.txt", myData, "Table"]
 

Similar threads

  • · Replies 52 ·
2
Replies
52
Views
12K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
1
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K