Mathematica: create b-file for OEIS

  • Mathematica
  • Thread starter jackmell
  • Start date
  • Tags
    Mathematica
In summary, The conversation is about saving a Mathematica array in the correct format for OEIS (On-Line Encyclopedia of Integer Sequences). The format requires one space between the first and second column and a CR at the end of the file. The code used to convert the array to the correct format is to first convert the values to strings and then manually format them by using a for loop to join the values with a space and then appending them to a list. The list is then exported to a text file using the "Table" format.
  • #1
jackmell
1,807
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
  • #2
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"]
 

Related to Mathematica: create b-file for OEIS

1. What is Mathematica and how is it used?

Mathematica is a powerful computational software program used for mathematical, scientific, and engineering applications. It allows users to perform complex calculations, create visualizations, and develop algorithms for data analysis and modeling.

2. What is a b-file and how is it used in OEIS?

A b-file is a text file that contains a sequence of numbers, typically used to represent integer sequences. In OEIS (the Online Encyclopedia of Integer Sequences), b-files are used to store and share sequences submitted by users. These files are used to generate visualizations and analyze the properties of the sequences.

3. How do you create a b-file in Mathematica?

To create a b-file in Mathematica, you can use the "Export" function with the "Table" command to generate a list of numbers. Then, you can use the "StringJoin" function to create a text string in the correct format for a b-file, with each number separated by a comma. Finally, you can use the "Export" function again to save the text string as a .txt file.

4. How do you submit a b-file to OEIS?

To submit a b-file to OEIS, first, make sure the file follows the correct format with each number on a separate line and a comment line at the top with the sequence name and description. Then, go to the "Additions" page on the OEIS website and fill out the submission form, including the b-file in the appropriate field. Once submitted, the sequence will go through a review process before being added to OEIS.

5. What are some tips for creating a high-quality b-file for OEIS?

When creating a b-file for OEIS, it is important to make sure the sequence is correctly represented and follows the proper format. Additionally, providing a detailed description and any relevant references can help with the review process. It is also recommended to check for duplicate sequences in OEIS before submitting. Finally, testing the sequence in Mathematica or other software can help catch any errors before submission.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
2
Replies
52
Views
12K
  • Calculus and Beyond Homework Help
Replies
2
Views
2K
  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
2
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
2K
  • Special and General Relativity
Replies
11
Views
2K
  • Special and General Relativity
Replies
1
Views
2K
Back
Top