Si vous ne souhaitez pas télécharger des convertisseurs tiers dans votre projet, une autre option consiste à écrire votre propre script pour convertir le fichier Excel à votre place. J'ai ajouté mon propre convertisseur en utilisant Python. Le script en python :
from pandas import DataFrame, read_excel
from argparse import ArgumentParser
from os import remove
def change_file_format_to_csv(filename):
filename = filename.split(".")
filename[-1] = 'csv'
if __name__ == "__main__":
# Parse arguments
parser = ArgumentParser()
parser.add_argument("-i", "--input", default="", required=False,
help="Input file to be converted")
args = parser.parse_args()
# Load input
print(args.input)
content = read_excel(args.input)
# Change filename to csv
filename_output = args.input.split(".")
filename_output[-1] = "csv"
filename_output = '.'.join(filename_output)
# Store input as CSV
content.to_csv(filename_output)
# Cat output to command line
with open(filename_output, 'r') as f:
print(f.read())
# Remove temporary file
remove(filename_output)
Ensuite, vous ajoutez (comme expliqué dans les autres réponses) le nom du script python à vos fichiers .git/config et .gitattributes.
.gitattributes :
*.xls diff=xls
.git/config :
[diff "xlsx"]
textconv = python ./utils/xlsx_to_csv.py --input