tdt_to_xlsx

Version 0.2 (14.2 KB) by Rhys Switzer
Read in a .tdt file, convert it to .txt, read in as a cell array, then save as a .xlsx file. Includes optional arguments for specifying save
11 Downloads
Updated 25 Jan 2022

MATLAB_tdt_to_xlsx

Reads in a .tdt file, converts it to .txt, reads this in as a cell array, then saves the cell array as a .xlsx file. Includes optional arguments for specifying saved file name, destination path, writecell WriteMode, and whether to save the .txt conversion. Returns the full path of the saved .xlsx file.

Arguments

Optional arguments are specified using the following name-value arguments:

  1. "XLSXFileName", some-string-here - A filename string that will be used as the name for the final .xlsx file. Defaults to the same name as the initial .tdt file.
  2. "DestinationPath", some-string-here - A path string that indicated where the final .xlsx file is saved. If you choose to save the .txt file, it will be saved here as well. Defaults to the same directory as the initial .tdt file.
  3. "SaveTXT", some-logical-here - A logical argument indicating whether you want to save the .txt conversion of the .tdt or have it automatically removed once the .xlsx has been written. Defaults to false.
  4. "WriteMode", some-string-here - A string argument that is passed to the writecell function's "WriteMode" argument in MATLAB to change the behavior of how writecell chooses to write or overwrite existing files. Defaults to 'replacefile'.

In cases where SaveTXT is set to false (or defaults), but a .txt already exists at the given save destination, the function will not delete the existing .txt file. This behavior can be changed by disabling lines 21 and 22 in the code.

Output

The function saves a .xlsx file and (optionally) a .txt conversion of the initial .tdt file. It also returns the full path to the saved .xlsx file.

Examples

Calling with default arguments and no return:

tdt_to_xlsx(tdt_file);

Calling with return and optional arguments:

path_to_saved_xlsx = tdt_to_xlsx(tdt_file, "XLSXFileName", coolfilenamehere, "DestinationPath", awesomepathhere, "SaveTxt", 1, "WriteMode", "overwritesheet")

Limitations

My current method of checking for and replacing "missing" values is a little convoluted and could probably be a lot better. I ran into issues with cellfun and ismissing triggering on any string with spaces. Feel free to make a pull request if you have a better way of handling it.

This function was originally designed for .tdt files outputted by NeuroGuide the EEG analysis software. Theoretically it should work with any non-proprietary tab-deliminated text file. Let me know if it doesn't.

Thanks for checking this out!

View tdt_to_xlsx on File Exchange

Cite As

Rhys Switzer (2024). tdt_to_xlsx (https://github.com/NotMyMajor/MATLAB_tdt_to_xlsx/releases/tag/V0.2), GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2021b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
0.2

See release notes for this release on GitHub: https://github.com/NotMyMajor/MATLAB_tdt_to_xlsx/releases/tag/V0.2

0.1

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.