Comments (4)
Hi, first off, im so rude... I must thank you for making this awesome library... really helpful!
Here's how im making sure i can get all the headers (for use with react-table
)
import { ROWS_TO_GLEAN_HEADERS_FROM } from "next.config";
// moved the const to config to make it easier to remember there's a bug laying in wait
// go through the dataset and make sure we have all the row headers
export const getItemsHeaders = (tableData) => {
if (typeof tableData === "undefined") return;
const headerSet = new Set(); // Collapse a Set to get the unique items
tableData.some((cell, index) => {
// just go through the first n rows
if (index > ROWS_TO_GLEAN_HEADERS_FROM) return; // NOTE: optimization which could cause a bug if the included rows do not contain all the headers
Object.keys(cell).forEach((key) => headerSet.add(key));
});
const headers = Array.from(headerSet); // collapse the set
return headers.map((header) => {
return {
Header: header.toUpperCase(),
accessor: header,
};
});
};
from use-google-sheets.
Can you make the PR to https://github.com/gglukmann/google-sheets-mapper?
from use-google-sheets.
What would like to have as header? Index of row?
from use-google-sheets.
Hi just seeing this.
Row zero would be the first row... usually that makes the table head. I solved the issue a while ago but, if i recall, if there's a blank cell in the sheet, it would create offset on that row? So we ahve to reduce to get all of the keys in the whole sheet to make the headers.
from use-google-sheets.
Related Issues (9)
- Feature Request: Get URL of "image in cell" HOT 1
- api key and sheet id exposed in network request HOT 1
- Feature Request: Be able to fetch data from restricted sheet HOT 1
- Feature Request: Add a new prop that lets us set the row number of the row we want to use for the header HOT 1
- Documentation Request - more clarity on how to get the key, HOT 1
- Is the data memoized? HOT 1
- Links in field values HOT 2
- The caller does not have permission HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from use-google-sheets.