Skip to content

csvexport troublesome when 'name' field contains commas #1049

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

Open
ni-balexand opened this issue May 21, 2025 · 1 comment
Open

csvexport troublesome when 'name' field contains commas #1049

ni-balexand opened this issue May 21, 2025 · 1 comment

Comments

@ni-balexand
Copy link

I'm using Tracy 0.11.1 on Windows / MSVC.

I've run into an issue that arises when the name of my function contains a comma. This will happen if ZoneScoped is used from a method in a class that has two template parameters, such as: namespace::ClassName<TemplateParamA,TemplateParamB>::methodName

Some potential workarounds:

  • Detect < when parsing the output of csvexport, and don't let commas separate the fields until a closing > is found
  • If only the first field potentially has a comma, a parser could potentially start with the last comma in the line and work backwards.
  • Use ZoneScopedN and pass a name that doesn't have commas

Hypothetically, the file path could also have a comma? Seems unlikely and weird, but that would derail any of those workarounds.

CSV conventions exist for this problem. Fields which contain a comma should be surrounded in double-quote characters, literal double-quote characters should be escaped using two double-quote characters. Unfortunately, this complicates what ought to be a dead-simple format.

Another solution could be to replace commas with something else, like a space, a colon, or some other special character before dumping to CSV.

Or, promote the usage of tab-separated values instead.

@ni-balexand
Copy link
Author

Just after publishing the issue, I found out that you can instruct the csvexport program to use a tab character as a separator using the -s option. Passing that from a shell (especially CMD) might be awkward, but it works somewhat seamlessly when invoking it from Python:

csv_export_program_args = [csv_export_program_path, "-s", "\t", str(tracy_file_path)]
csv_export_program_proc = subprocess.Popen(csv_export_program_args, stdout=PIPE)
(csv_data_raw, _) = csv_export_program_proc.communicate(timeout=120)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant