KansaiRobot
KansaiRobot

Reputation: 10052

Using github for excel files

As a kind of follow up of this question, I would like to ask regarding binary files (such us excel files) and versioning.

Let's say I want to use github to store a programming project. No problem there since the majority of files are text (no matter the language).

But I have also documentation. What if I put it into a folder of the github project? (I have seen projects that do this)

I read git is no good for this, so how can I work versioning for say excel files?

Upvotes: 7

Views: 31400

Answers (3)

You can use the CSV format, which is supported by Microsoft office, and is not hard to parse. Here is an example of one:

A1,B1
C1,D1

Upvotes: 1

rob006
rob006

Reputation: 22174

You could save your excel as .fods, which is regular .ods file saved as flat XML. This format is probably not supported by MS Office, so you may need to install Libre Office for this (it is free).

Since .fods is regular XML, it can be versioned as regular text file with diffs and (with some luck) even support of merges between branches.

You could also save other Open Document formats as flat XMLs:

  • .fodt for word processing (text) documents
  • .fods for spreadsheets
  • .fodp for presentations
  • .fodg for graphics

So if migration to Libre Office is not a problem, this is probably the best solution.


If this is not an option, you may consider using Git LFS for storing binaries. But if files are small and you don't change them often, you can just ignore the whole problem - few small binary files will not hurt your repository. You should just estimate - if you will start versioning 1 MB binary file and save 100 versions of it, this will increase size of your repository about 100 MB (it could be smaller if file can be compressed). You need a really large codebase to reach 100 MB in repository with text source files only, so in this case your repository will be filled mainly by binary files.

BTW: GitHub released a tool for measuring size of git repository: git-sizer. It may give you some hints about potential problems with your repository.

Upvotes: 8

Praveen Kumar A X
Praveen Kumar A X

Reputation: 431

//FIRST RUN THIS COMMAND
//npm install xlsx jsonfile

//CHANGE INPUT FILE NAME TO sample.xlsx and OUTPUT file is data.json

var XLSX = require('xlsx'),
request = require('request');
var fs = require('fs');
var jsonfile = require('jsonfile')

var file = 'data.json'

var buf = fs.readFileSync("sample.xlsx");
var wb = XLSX.read(buf, {type:'buffer'});

console.log(wb.Sheets);

jsonfile.writeFile(file, wb.Sheets, function (err) {
  console.error(err)
})

Interesting question.Simple answer to it is, 'write some code to convert your excel file(.xls or .xlsx) to a json file and upload the content to git.

This idea is valid only for a simple excel sheet and not for complex ones involving a lot of math and charts.

Upvotes: 1

Related Questions