Title: Better way to store updatable scientific data?
Tags: database
Question: I am using a file consisting of published scientific data. I'm using this file with a program that reads in the first 5 space delimited data fields, and everything after that is considered a comment by the program. 

2 example lines (of thousands):

```FeII 1608.4511 0.521 55.36 -1300 M03 Journal of Physics
FeII 1611.23045 0.0321 55.36 1100 01J AJ
```

The program reads it as: 

```FeII 1608.4511 0.521 55.36 -1300 
FeII 1611.23045 0.0321 55.36 1100 
```

These numbers are each measurements and most (don't get me started) have associated errors that are not listed in this file. I would like to store this information in a useful and updatable way. That is, say the first entry FeII 1608.4511 has an error of plus/minus 0.002. Consider when a new measurement is made and changes it to: FeII 1608.45034 plus/minus 0.0005. I would like to update the value, the error, and record some information about the publication that it came from.

The program that uses this file is legacy code and is both crucial and inflexible: and it needs the file to look like the above output when it's read in. I would really like for there to be a way to update the input file to include things like errors on the values and publication hyperlinks in comments. I would also like a kind of version control ability to return the state of this large file today; or in 5 months after 20 more lines are updated with new values.

Any suggestions on how best to accomplish this? Should I store everything in some kind of database? 

Comment: @Catcall, you are striking at the heart of my concerns... I could do each change on the correct line by hand on the file easily from context clues in the publication. However, how do I choose to label them within the database? And there are entries like this: 
C I** 1277.5501
C I** 1277.7233
-- so each change is probably uniquely identified by the letters plus the next 5 digits? But what if I add new data that needs to go to 6 digits? What if the 6th digit of needs to be updated on another line?

Comment: How do you know this new value, FeII 1608.45034 ± 0.0005, is supposed to update FeII 1608.4511 ± 0.002 rather than the row FeII 1611.23045?

Here is the accepted answer: Databases are deeply tied to identity. If a database can't identify a row by the data that's in it, a database isn't going to help you.

If I were you, I'd start by storing the base file in a version control system, not a database. At 20 changes per 5 months, I'd probably make those changes manually and commit each batch of changes. (I don't know what might constitute a batch for you. Could be a single change every time.) 

Since the format of the existing file is both crucial and brittle, I'm not sure whether modifying it is a good idea. I think I'd feel better about storing error ranges and publication hyperlinks in a separate file, and using a script to put the pieces together for applications that can use error ranges and hyperlinks.


Here is another answer: For updating the information in the file introducing errors and links, you don't need any database; just open the file, iterate through the lines and update each one.

If you want to be able to restore a line state, you definetively need some kind of database. You can create a database in Sql Server or Firebird for example, and store in it a row for each line historical state (with date of creation off course); your file itself would be the repository for current values and you would be able to restore the file with a date and some simple fetcing of the database information.

If you can't use a database like Firebird or SQL Server, you can store the historical data in a simple text file, it's up to you. Just remember that you necesarely will need, like @CatCall commented, a way to identify each line in order to create a relation between the line in the file and the historical data stored in your repository.


Here is another answer: A database sounds sensible, SQL Server Express is free and widely used.

You can read in the text file including all comments and output the edited data in the same format. You can use a number of front ends including Access, for rapid development, or something you create yourself in VB.Net, or even Excel, at a pinch.

You will need to consider the structure of the table(s) but it should not be too difficult, and you can get help here.


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 3, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2011:00:08/30/11', 'FavoriteCount': 0.0, 'PostTypeId': 1, 'Tags': '<database>', 'Title': 'Better way to store updatable scientific data?', 'ViewCount': 297, 'id': 7240702, 'user_AboutMe': '', 'user_AccountId': 89481.0, 'user_DisplayName': 'JBWhitmore', 'user_Reputation': 11046.0, 'user_Views': 289.0, 'user_id': 246856.0}}