Skip to content
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

Exporting main metrics with a period of "week" as CSV produces broken exports #17441

Closed
ziegenberg opened this issue Apr 9, 2021 · 2 comments · Fixed by #17442
Closed

Exporting main metrics with a period of "week" as CSV produces broken exports #17441

ziegenberg opened this issue Apr 9, 2021 · 2 comments · Fixed by #17442
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@ziegenberg
Copy link
Contributor

When exporting the main metrics with a period of week as CSV the resulting export is broken, because the date span contains a comma, which is also the column separator used in CSVs.

Expected Behavior

Exporting main metrics with a period of week as CSV results in usable data.
Example:

Date,Unique visitors,Visits,Users,Actions,Maximum actions in one visit,Bounces,Total time spent by visitors (in seconds),New Visits,Actions by New Visits,Unique new visitors,New Users,max_actions_new,Bounce Rate for New Visits,Avg. Actions per New Visit,Avg. Duration of a New Visit (in sec),Visitors from Search Engines,Visitors from Social Networks,Visitors from Direct Entry,Visitors from Websites,Visitors from Campaigns,Percent of Visitors from Direct Entry,Percent of Visitors from Search Engines,Percent of Visitors from Campaigns,Percent of Visitors from Social Networks,Percent of Visitors from Websites,PagePerformance_network_time,PagePerformance_network_hits,PagePerformance_servery_time,PagePerformance_server_hits,PagePerformance_transfer_time,PagePerformance_transfer_hits,PagePerformance_domprocessing_time,PagePerformance_domprocessing_hits,PagePerformance_domcompletion_time,PagePerformance_domcompletion_hits,PagePerformance_onload_time,PagePerformance_onload_hits,PagePerformance_pageload_time,PagePerformance_pageload_hits,Avg. network time,Avg. server time,Avg. transfer time,Avg. DOM processing time,Avg. DOM completion time,Avg. on load time,Avg. page load time,Conversions,Visits with Conversions,Revenue,Conversion Rate,nb_conversions_new_visit,nb_visits_converted_new_visit,revenue_new_visit,conversion_rate_new_visit,Pageviews,Unique Pageviews,Downloads,Unique Downloads,Outlinks,Unique Outlinks,Searches,Unique Keywords,Bounce Rate,Actions per Visit,Avg. Visit Duration (in seconds),Avg. Duration of a Returning Visit (in sec),Avg. Actions per Returning Visit,Bounce Rate for Returning Visits,Returning Visits,Actions by Returning Visits,Unique returning visitors,Returning Users,Maximum actions in one returning visit,Distinct search engines,Distinct social networks,Distinct keywords,Distinct websites,Referrers_distinctWebsitesUrls,Distinct campaigns,nb_conversions_returning_visit,nb_visits_converted_returning_visit,revenue_returning_visit,conversion_rate_returning_visit
"2021-02-22,2021-02-28",1,1,0,1,1,1,0,1,1,1,0,1,100%,1,0s,0,0,1,0,0,0%,0%,0%,0%,0%,0.15,1,0.549,1,0.073,1,0.466,1,0.562,1,0.066,1,1.866,1,0.15s,0.55s,0.07s,0.47s,0.56s,0.07s,1.87s,0,0,0,0%,0,0,0,0%,1,1,0,0,0,0,0,0,100%,1,0s,0s,0,0%
"2021-03-15,2021-03-21",448,1228,36,2317,23,805,136761,530,1012,422,36,23,67%,1.9,2 min 26s,319,110,171,521,107,1%,2%,1%,1%,3%,136.293,1234,602.219,1234,206.332,1234,1393.43,1234,864.863,1234,234.408,1234,3437.545,1234,0.11s,0.49s,0.17s,1.13s,0.7s,0.19s,2.79s,204,184,35268.78,14.98%,66,32,16804.19,6.04%,1831,1553,110,110,80,80,37,29,66%,1.9,1 min 51s,1 min 25s,1.9,65%,698,1305,299,31,23,9,3,131,153,239,12,0,0,0,0%

Current Behavior

Exporting main metrics with a period of week as CSV results in broken data.
Example:

Date,Unique visitors,Visits,Users,Actions,Maximum actions in one visit,Bounces,Total time spent by visitors (in seconds),New Visits,Actions by New Visits,Unique new visitors,New Users,max_actions_new,Bounce Rate for New Visits,Avg. Actions per New Visit,Avg. Duration of a New Visit (in sec),Visitors from Search Engines,Visitors from Social Networks,Visitors from Direct Entry,Visitors from Websites,Visitors from Campaigns,Percent of Visitors from Direct Entry,Percent of Visitors from Search Engines,Percent of Visitors from Campaigns,Percent of Visitors from Social Networks,Percent of Visitors from Websites,PagePerformance_network_time,PagePerformance_network_hits,PagePerformance_servery_time,PagePerformance_server_hits,PagePerformance_transfer_time,PagePerformance_transfer_hits,PagePerformance_domprocessing_time,PagePerformance_domprocessing_hits,PagePerformance_domcompletion_time,PagePerformance_domcompletion_hits,PagePerformance_onload_time,PagePerformance_onload_hits,PagePerformance_pageload_time,PagePerformance_pageload_hits,Avg. network time,Avg. server time,Avg. transfer time,Avg. DOM processing time,Avg. DOM completion time,Avg. on load time,Avg. page load time,Conversions,Visits with Conversions,Revenue,Conversion Rate,nb_conversions_new_visit,nb_visits_converted_new_visit,revenue_new_visit,conversion_rate_new_visit,Pageviews,Unique Pageviews,Downloads,Unique Downloads,Outlinks,Unique Outlinks,Searches,Unique Keywords,Bounce Rate,Actions per Visit,Avg. Visit Duration (in seconds),Avg. Duration of a Returning Visit (in sec),Avg. Actions per Returning Visit,Bounce Rate for Returning Visits,Returning Visits,Actions by Returning Visits,Unique returning visitors,Returning Users,Maximum actions in one returning visit,Distinct search engines,Distinct social networks,Distinct keywords,Distinct websites,Referrers_distinctWebsitesUrls,Distinct campaigns,nb_conversions_returning_visit,nb_visits_converted_returning_visit,revenue_returning_visit,conversion_rate_returning_visit
2021-02-22,2021-02-28,1,1,0,1,1,1,0,1,1,1,0,1,100%,1,0s,0,0,1,0,0,0%,0%,0%,0%,0%,0.15,1,0.549,1,0.073,1,0.466,1,0.562,1,0.066,1,1.866,1,0.15s,0.55s,0.07s,0.47s,0.56s,0.07s,1.87s,0,0,0,0%,0,0,0,0%,1,1,0,0,0,0,0,0,100%,1,0s,0s,0,0%
2021-03-15,2021-03-21,448,1228,36,2317,23,805,136761,530,1012,422,36,23,67%,1.9,2 min 26s,319,110,171,521,107,1%,2%,1%,1%,3%,136.293,1234,602.219,1234,206.332,1234,1393.43,1234,864.863,1234,234.408,1234,3437.545,1234,0.11s,0.49s,0.17s,1.13s,0.7s,0.19s,2.79s,204,184,35268.78,14.98%,66,32,16804.19,6.04%,1831,1553,110,110,80,80,37,29,66%,1.9,1 min 51s,1 min 25s,1.9,65%,698,1305,299,31,23,9,3,131,153,239,12,0,0,0,0%

Possible Solution

Escape the date span for exports with a period of week using double quotes. Or use a different character between the two dates in the date span.

Steps to Reproduce (for Bugs)

  1. Go to "Visitors" > "Overview"
  2. At the "Visits Over Time" graph change the period to "week"
  3. Export the dataset with export format "CSV".
  4. The CSV is broken.

This is reproducible on https://demo.matomo.cloud

Context

--

Your Environment

  • Matomo Version: 4.2.1
  • PHP Version: 8.0.3
  • Server Operating System: CentOS 8.3
  • Additionally installed plugins:
  • Browser:
  • Operating System:
@ziegenberg ziegenberg added the Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. label Apr 9, 2021
@ziegenberg ziegenberg changed the title exporting main metrics with period of "week" as CSV produces broken exports Exporting main metrics with a period of "week" as CSV produces broken exports Apr 9, 2021
@sgiehl
Copy link
Member

sgiehl commented Apr 9, 2021

Hi @ziegenberg. Thanks for creating this issue. I was able to reproduce. This should indeed be escaped correctly.

@sgiehl sgiehl added Bug For errors / faults / flaws / inconsistencies etc. and removed Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. labels Apr 9, 2021
@ziegenberg
Copy link
Contributor Author

PR incoming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants