Skip to content

Instantly share code, notes, and snippets.

@shubhamagarwal92
Created August 19, 2018 14:35
Show Gist options
  • Save shubhamagarwal92/a133cc06cf8cf08052913cc0642614c4 to your computer and use it in GitHub Desktop.
Save shubhamagarwal92/a133cc06cf8cf08052913cc0642614c4 to your computer and use it in GitHub Desktop.
This script allows to convert excel line (space separated line) to latex table line format
__author__='shubhamagarwal92'
"""
This script allows to convert excel line (space separated line)
to latex table line format
Usage:
Input:
>>> Enter text: ABC 0.4742 0.7770 0.8717 4.9432 0.6126
Output:
>>> ABC & 0.4742 & 0.7770 & 0.8717 & 4.9432 & 0.6126 \\
"""
if __name__=='__main__':
while True:
try:
text = raw_input("Enter text: ")
if text == "stop" or "":
break
out_latex_str = ' & '.join(text.split(' '))
# Add double backslash at the end
out_latex_str = out_latex_str + ' \\\\'
print(out_latex_str)
except KeyboardInterrupt:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment