# getCSV output nothing

**URL:** <https://discourse.gohugo.io/t/getcsv-output-nothing/32052>\
**Category:** support\
**Created:** [March 30, 2021, 5:06am UTC](https://discourse.gohugo.io/t/getcsv-output-nothing/32052 "2021-03-30T05:06:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![tsq456](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tsq456/32/13999_2.png) [@tsq456](https://discourse.gohugo.io/u/tsq456)\
**Post date:** [March 30, 2021, 5:06am UTC](https://discourse.gohugo.io/t/getcsv-output-nothing/32052/1 "2021-03-30T05:06:49Z")

</div>

I want to get value of a cell given row and column number, so I use the code below, but it output nothing.

```auto
{ $url := "https://docs.google.com/spreadsheets/d/1N8480w1hPyilUS4qK1rnSY6RiE-OX-2hy1glQCTRh_w/export?format=csv&gid=1124904396" }}
    {{ $sep := "," }}
    {{ $csv := getCSV $sep $url }}
    {{ $r := 12 }}
    {{ $c := 2 }}
    <i>
      {{ range $i,$csv }}
        {{ index ( index $csv $r ) $c }}   
      {{ end }}
    </I>

```

Someone can help me?

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [March 30, 2021, 5:14am UTC](https://discourse.gohugo.io/t/getcsv-output-nothing/32052/2 "2021-03-30T05:14:21Z")

</div>

This is not a Hugo issue.

The CSV is private: You either need to make it public or use authentication.

---

<div class="post-metadata">

**Author:** ![tsq456](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tsq456/32/13999_2.png) [@tsq456](https://discourse.gohugo.io/u/tsq456)\
**Post date:** [March 30, 2021, 5:27am UTC](https://discourse.gohugo.io/t/getcsv-output-nothing/32052/4 "2021-03-30T05:27:24Z")

</div>

I tried to put csv file in the local static folder, and I got the same result.

```
    {{ $url := "csv/test.csv" }}
{{ $sep := "," }}
{{ $csv := getCSV $sep $url }}
{{ $r := 12 }}
{{ $c := 2 }}
<i>
  {{ range $i,$csv }}
    {{ index ( index $csv $r ) $c }}   
  {{ end }}
</i>
```

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [March 30, 2021, 5:29am UTC](https://discourse.gohugo.io/t/getcsv-output-nothing/32052/5 "2021-03-30T05:29:10Z")

</div>

Try putting it in the data folder.

Also see the example for CSV.

> **[Data Templates](https://gohugo.io/templates/data-templates/#the-data-folder)**
>
> In addition to Hugo's built-in variables, you can specify your own custom data in templates or shortcodes that pull from both local and dynamic sources.

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [March 30, 2021, 12:14pm UTC](https://discourse.gohugo.io/t/getcsv-output-nothing/32052/6 "2021-03-30T12:14:52Z")

</div>

I think this line alone without the range should output row 13, column 3:

```auto
{{ index ( index $csv $r ) $c }}

```

It starts with 0, so always add a `-1` to the variables where you set the location of the cell.  
Then remove the range part, because if you range inside of it the dot (`.`) is one row, so you could access the column by using {{ index . $c }}. But: you would access that column in EVERY row, so take away the range line and the end line and try again.

Other than that 😉 put a sample online.

---

<div class="post-metadata">

**Author:** ![tsq456](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tsq456/32/13999_2.png) [@tsq456](https://discourse.gohugo.io/u/tsq456)\
**Post date:** [March 30, 2021, 1:10pm UTC](https://discourse.gohugo.io/t/getcsv-output-nothing/32052/7 "2021-03-30T13:10:23Z")

</div>

Thanks a lot! I removed the {{range}} part, and it output the right result with local csv file now.

but when I use the google spreadsheet csv url, console remind me the infomation below.

> ERROR 2021/03/30 21:05:28 Failed to get CSV resource “[https://docs.google.com/spreadsheets/d/1N8480w1hPyilUS4qK1rnSY6RiE-OX-2hy1glQCTRh\_w/export?format=csv](https://docs.google.com/spreadsheets/d/1N8480w1hPyilUS4qK1rnSY6RiE-OX-2hy1glQCTRh_w/export?format=csv)”: failed to parse CSV file [https://docs.google.com/spreadsheets/d/1N8480w1hPyilUS4qK1rnSY6RiE-OX-2hy1glQCTRh\_w/export?format=csv:](https://docs.google.com/spreadsheets/d/1N8480w1hPyilUS4qK1rnSY6RiE-OX-2hy1glQCTRh_w/export?format=csv:) parse error on line 3, column 11: bare " in non-quoted-field  
> If you feel that this should not be logged as an ERROR, you can ignore it by adding this to your site config:  
> ignoreErrors = [“error-remote-getcsv”]  
> ERROR 2021/03/30 21:05:28 render of “page” failed: execute of template failed: template: \_default/single.html:9:6: executing “main” at \<index (index $csv 1) 1\>: error calling index: index of untyped nil  
> ERROR 2021/03/30 21:05:28 render of “page” failed: execute of template failed: template: \_default/single.html:9:6: executing “main” at \<index (index $csv 1) 1\>: error calling index: index of untyped nil  
> ERROR 2021/03/30 21:05:28 render of “page” failed: execute of template failed: template: \_default/single.html:9:6: executing “main” at \<index (index $csv 1) 1\>: error calling index: index of untyped nil  
> ERROR 2021/03/30 21:05:28 render of “page” failed: execute of template failed: template: \_default/single.html:9:6: executing “main” at \<index (index $csv 1) 1\>: error calling index: index of untyped nil  
> Built in 32175 ms  
> Error: Error building site: failed to render pages: render of “page” failed: execute of template failed: template: \_default/single.html:9:6: executing “main” at \<index (index $csv 1) 1\>: error calling index: index of untyped nil

Is this caused by authentication issues ?

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [March 30, 2021, 1:12pm UTC](https://discourse.gohugo.io/t/getcsv-output-nothing/32052/8 "2021-03-30T13:12:16Z")

</div>

This is because you did not publish your spreadsheet properly. You need to set it to public because getCSV does not add any authentication to the file.

---

<div class="post-metadata">

**Author:** ![tsq456](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/tsq456/32/13999_2.png) [@tsq456](https://discourse.gohugo.io/u/tsq456)\
**Post date:** [March 30, 2021, 1:16pm UTC](https://discourse.gohugo.io/t/getcsv-output-nothing/32052/9 "2021-03-30T13:16:05Z")

</div>

Yeah, I found that I forgot to publish my spreadsheet lol. Thanks for ur help! ^^

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [April 1, 2021, 1:16pm UTC](https://discourse.gohugo.io/t/getcsv-output-nothing/32052/10 "2021-04-01T13:16:19Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
