# Large posts in staff logs break Excel CSV format

**URL:** https://meta.discourse.org/t/large-posts-in-staff-logs-break-excel-csv-format/104719
**Category:** Bug
**Created:** [December 19, 2018, 11:16pm UTC](https://meta.discourse.org/t/large-posts-in-staff-logs-break-excel-csv-format/104719 "2018-12-19T23:16:51Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [December 19, 2018, 11:16pm UTC](https://meta.discourse.org/t/large-posts-in-staff-logs-break-excel-csv-format/104719/1 "2018-12-19T23:16:51Z")

</div>

Staff can export staff logs from `/admin/logs/staff_action_logs` to see the full history, as we only display a subset of logs within the admin UI. Certain logs can have commas included in the details, which break formatting of the CSV.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [December 20, 2018, 12:45am UTC](https://meta.discourse.org/t/large-posts-in-staff-logs-break-excel-csv-format/104719/2 "2018-12-20T00:45:03Z")

</div>

Can commas be escaped in this output @vinothkannans?

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [December 20, 2018, 10:55am UTC](https://meta.discourse.org/t/large-posts-in-staff-logs-break-excel-csv-format/104719/4 "2018-12-20T10:55:48Z")

</div>

No, the commas are not breaking the CSV file. Maximum number of characters allowed in a single cell of MS Excel sheet is **32,767**. If a column exceeded the characters limit then it’s breaking the CSV format. In our case `details` column having more characters in some `post_edit` staff actions. If I open the same CSV file in Google Sheets then it renders all the columns correctly.

If needed I’ll limit the maximum number of characters for `details` column to ~30,000 in the export unconditionally.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [December 21, 2018, 2:31am UTC](https://meta.discourse.org/t/large-posts-in-staff-logs-break-excel-csv-format/104719/5 "2018-12-21T02:31:47Z")

</div>

30k chars still seems like a _lot_. Do we need that many characters in a cell? If so, _why?_

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [December 21, 2018, 2:41am UTC](https://meta.discourse.org/t/large-posts-in-staff-logs-break-excel-csv-format/104719/6 "2018-12-21T02:41:09Z")

</div>

It’s due to giant posts. For example, many of our internal runbooks tend to be quite long. Likely only the `post_edit` staff action as Vinoth noted would have this many characters.

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [December 21, 2018, 2:44am UTC](https://meta.discourse.org/t/large-posts-in-staff-logs-break-excel-csv-format/104719/7 "2018-12-21T02:44:16Z")

</div>

Also we storing both old and new post raws for post\_edit staff actions in [discourse/app/services/staff\_action\_logger.rb at 4383afb769d97bc9724d5448c0583b14c39782d0 · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/4383afb769d97bc9724d5448c0583b14c39782d0/app/services/staff_action_logger.rb#L133).

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [December 21, 2018, 2:45am UTC](https://meta.discourse.org/t/large-posts-in-staff-logs-break-excel-csv-format/104719/8 "2018-12-21T02:45:15Z")

</div>

We should _aggressively_ truncate this, I don’t see the point of creating such bulk in the database over something so trivial.

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [December 21, 2018, 2:48am UTC](https://meta.discourse.org/t/large-posts-in-staff-logs-break-excel-csv-format/104719/9 "2018-12-21T02:48:52Z")

</div>

Okay, I’ll try to improve this by storing only the edit differences in the raw text.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [November 4, 2020, 12:44am UTC](https://meta.discourse.org/t/large-posts-in-staff-logs-break-excel-csv-format/104719/10 "2020-11-04T00:44:26Z")

</div>

I would like to close this one off. Let’s do the simple thing here, restrict cells to 30k, then close this. The delta stuff is a very very complex change.

---

<div class="post-metadata">

### Author: ![nat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nat/32/235063_2.png) [@nat](https://meta.discourse.org/u/nat)
#### Post date: [April 5, 2022, 3:13am UTC](https://meta.discourse.org/t/large-posts-in-staff-logs-break-excel-csv-format/104719/11 "2022-04-05T03:13:59Z")

</div>



---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [June 24, 2022, 4:10pm UTC](https://meta.discourse.org/t/large-posts-in-staff-logs-break-excel-csv-format/104719/14 "2022-06-24T16:10:02Z")

</div>



---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [June 24, 2022, 4:10pm UTC](https://meta.discourse.org/t/large-posts-in-staff-logs-break-excel-csv-format/104719/15 "2022-06-24T16:10:49Z")

</div>

Re-opening this. We need to get some sort of fix in place, it’s near impossible to review exported logs with giant posts breaking the formatting.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [June 27, 2022, 7:43am UTC](https://meta.discourse.org/t/large-posts-in-staff-logs-break-excel-csv-format/104719/22 "2022-06-27T07:43:08Z")

</div>

Perhaps the simplest fix here is:

```plaintext
> '"' + 'post "body" ' .gsub('"', '""') + '"'
=> "\"post \"\"body\"\" \""

```

I think this is allowed in CSV and should work.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [August 24, 2026, 8:41am UTC](https://meta.discourse.org/t/large-posts-in-staff-logs-break-excel-csv-format/104719/23 "2026-08-24T08:41:58Z")

</div>

@jomaxro is this still happening? current discourse does escaping for , so we should not be corrupting your excels.

That said I don’t mind expanding our backup bundle to include jsonl/xlsx and csv … it makes this more generally useful and jsonl is lossless.
