-
-
Notifications
You must be signed in to change notification settings - Fork 298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Libra to openScale conversion script #1050
Comments
The Python script you've provided already includes the functionality to convert weight from pounds (lbs) to kilograms (kg). The conversion is controlled by the Here's the relevant part of the script: if (len(sys.argv) > 2) and (sys.argv[2] == 'lbs'):
print('Converting Libra data from lbs to kg')
weight_scalar = 0.453592
else:
print('Leaving Libra data as-is (kg)')
weight_scalar = 1 And here's where the conversion is applied: weight_float = float(w[1]) * weight_scalar So, if you want to convert the weight values from lbs to kg, you should run the script with 'lbs' as an argument, like this: python libra_to_openscale.py Libra_2024-06-04.csv lbs This will convert the weight values from lbs to kg before writing them to the output CSV file. If you run the script without 'lbs' as an argument, it will assume the weight values are already in kg and will not perform any conversion. I hope this helps! Let me know if you have any other questions. |
Ah, sorry if I wasn't clear. What I was suggesting was taking the script I included (the one you point out does have code to handle lbs conversion) and putting that in the wiki in place of this one already there, which uses Python 2 and does not have the ability to convert from lbs. I would have liked to make a PR instead of open this issue, since I have a proposed solution/code to my problem, but I can't see a way to open a PR to change a wiki page. |
Thanks for your updated script I replaced it in the wiki https://github.com/oliexdev/openScale/wiki/Useful-import-scripts#libra-csv-file----openscale-csv-file |
Is your feature request related to a problem? Please describe.
The existing Libra to openScale conversion script in the Wiki didn't work in Python 3. Also, I had issues when importing my data because Libra exported lbs and it looks like openScale expected kg
Describe the solution you'd like
I updated the script to work for Python 3, and added an argument to tell the script it needs to convert from lbs to kg for the final file. https://gist.github.com/abatula/3bb6d83ce2d8ea1c906efbb55e933d37
Describe alternatives you've considered
Any feedback on the script and I'd be happy to change it. Or if there's a way to PR the wiki I can move this there.
Additional context
N/A
The text was updated successfully, but these errors were encountered: