Support writing CSV to GCS
State: closed

- [x] fixes #23094 
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

This seems to work as-is and doesn't break any of the IO tests; as I mentioned in https://github.com/pandas-dev/pandas/issues/8508#issuecomment-421184687 getting S3 to work is a little more complicated but maybe still not bad. But this would be a step in the right direction regardless.

cc @TomAugspurger 

Labels:
name: Enhancement
name: IO Data
description: IO issues that don't fit into a more specific label

Comments:
Hello @bnaul! Thanks for submitting the PR.

 - There are no PEP8 issues in the file [`pandas/io/formats/csvs.py`](https://github.com/bnaul/pandas/blob/62e65f1f4478aac9d7f3a09cde6e95f4f9b5e50c/pandas/io/formats/csvs.py) !

 - There are no PEP8 issues in the file [`pandas/tests/io/test_gcs.py`](https://github.com/bnaul/pandas/blob/62e65f1f4478aac9d7f3a09cde6e95f4f9b5e50c/pandas/tests/io/test_gcs.py) !


Could also use a related issue and whatsnew note for v0.24
When reading S3, we have to wrap it in a TextIOWrapper. Do we need to do the same for writing?
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22704?src=pr&el=h1) Report
> Merging [#22704](https://codecov.io/gh/pandas-dev/pandas/pull/22704?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/c8ce3d01e9ffafc24c6f9dd568cd9eb7e42c610c?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/22704/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/22704?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master   #22704   +/-   ##
=======================================
  Coverage    92.2%    92.2%           
=======================================
  Files         169      169           
  Lines       50924    50924           
=======================================
  Hits        46952    46952           
  Misses       3972     3972
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.62% <100%> (ø)` | :arrow_up: |
| #single | `42.3% <100%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/22704?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/formats/csvs.py](https://codecov.io/gh/pandas-dev/pandas/pull/22704/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvY3N2cy5weQ==) | `98.21% <100%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22704?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22704?src=pr&el=footer). Last update [c8ce3d0...b2f97cc](https://codecov.io/gh/pandas-dev/pandas/pull/22704?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

Hi @WillAyd @TomAugspurger,

- Just added a whatsnew/related issue
- The `TextIOWrapper` thing would indeed be needed for `s3fs` for but `gcsfs` it isn't; I'd like to keep this small so for now I'm going to take care of the easier case first

If anyone else wants to take a look at this I would be grateful since touching anything related to `to_csv` makes me a bit nervous 😬 
Thanks @bnaul !
@bnaul Looks like there's no documentation on how to use this feature.  Hate to see this being implemented but no one is aware of it at all.
@5amfung can you submit a PR?