python-fitparse icon indicating copy to clipboard operation
python-fitparse copied to clipboard

Add FitFileEncoder for writing FIT files

Open xmedeko opened this issue 6 years ago • 5 comments

Fix #8

I have started with FitFileEncoder, see the test_encoder.py. I will rebase this PR while fixing the FitFileEncoder and edit this initial message.

The messages are created by DataMessageCreator just to keep quite a lot of code outside of the core DataMessage.

Cannot write:

  • compound fields,
  • accumulated fields,
  • developer fields.

But these fields are not necessary for an application generated FIT files. The compound and accumulated fields are designed to save a few bits of the resulting FIT file, which is not necessary for a server generated files and, furthermore, I need to use simple FIT features only to make some weak FIT parsers also working.

@dtcooper @pR0Ps Please review the code. I would appreciate to move some code changes out of this PR and merge it to master to make this PR smaller and simpler to review:

  • fileish_open, see #54
  • RFTC Crc, see the commit "RFCT move crc computation to records.Crc, add test". Also speeds up the FitFile when CRC is ignored.
  • Move apply_scale_offset to the records.py, what about to merge it to the field.render code?
  • Solve the optimisations #57
  • Rename FitFileDataProcessor.process_xxx methods to parse_xxx
  • Add BaseTyp.invalid_value, so as the parse does not need to be defined in most of times.

Thank you

xmedeko avatar Mar 09 '18 15:03 xmedeko

@pR0Ps I've addressed most of the comments by amend. See the rest. Do not want to merge it into the master until #57 is resolved.

xmedeko avatar Apr 12 '18 20:04 xmedeko

+1 writing fit files will be useful ! Please see my PR on @xmedeko fork which includes some scripts to fix FIT files or combine them into multi-sport ativities: [pull request on xmedeko fork] (https://github.com/xmedeko/python-fitparse/pull/1) Unfortunately there are conflicts with upstream.... I've not changed anything yet as I can see some different opinions in this stream...

vlcvboyer avatar Jan 03 '19 10:01 vlcvboyer

+1 would love to see this merged as well!

23chrischen avatar Feb 01 '19 12:02 23chrischen

+1, would love to have this merged in master. Will have to clone this manually to get access to this new feature for now ! Thanks for this !!

Kypaz avatar Jun 05 '19 08:06 Kypaz

I am sorry but I do not plan to maintain this PR and resolve conflicts due to the development in the master. Personally, I have decided do abandon FIT writing (and parsing, too) in pure Python since the FIT format is loosely specified and complex. I recommend to make some FIT<-->JSON tool from the original FIT SDK (e.g. C#, Java, C++) and just call this tool from Python.

xmedeko avatar Jun 05 '19 09:06 xmedeko