Django Table - loading data table, accessing values
My background is 100% in Excel VBA. But I'm working on building some of my first web applications in Django framework. Please pardon me if this question is ridiculous.
I have a giant table (5000 rows x 7 columns) in a CSV file. I would like to somehow load this table into the Django framework -- and access the values in the table.
If the table were smaller, I could create a new model, then load the CSV into the model. But instinctively, it feels wrong to create a model with thousands of fields. Is there another way to load the table into Django framework, and reference the values via something like a vlookup function?
Thank you for any assistance!
django
add a comment |
My background is 100% in Excel VBA. But I'm working on building some of my first web applications in Django framework. Please pardon me if this question is ridiculous.
I have a giant table (5000 rows x 7 columns) in a CSV file. I would like to somehow load this table into the Django framework -- and access the values in the table.
If the table were smaller, I could create a new model, then load the CSV into the model. But instinctively, it feels wrong to create a model with thousands of fields. Is there another way to load the table into Django framework, and reference the values via something like a vlookup function?
Thank you for any assistance!
django
7 columns seems very reasonable for a model. On mobile but lookup some articles on introductions to dbs. A good first one is MySQL. Then read more on Django's orm. The answer is to make a model with fields for the seven columns. Then read the csv and insert the rows through Django's orm.
– dennmat
Dec 28 '18 at 23:42
Ty Dennmat. So the columns are geographic areas (like CITY, COUNTY, STATE). But all of the rows are unique. For example, row 100 could be "POPULATION_2000" -- then in the columns it would have City population as of 2000, County population as of 2000, etc. So if I wanted to access the "Population in 2000 for the City" --- how could I "lookup" to find the correct Row/Column intersection to get the value I want?
– Mark1937
Dec 29 '18 at 0:15
You could add a Year field to the model then when querying you could do stuff like. Population.objects.filter(year=2000, city='New York') and that would give you the row(s) that match New York and the Year 2000. It's hard to answer without having a clearer view of what the CSV structure really is.
– dennmat
Dec 29 '18 at 1:02
Thank you very much. I will explore the objects.FILTER technique, and see how that goes. It seems promising.
– Mark1937
Dec 30 '18 at 21:06
add a comment |
My background is 100% in Excel VBA. But I'm working on building some of my first web applications in Django framework. Please pardon me if this question is ridiculous.
I have a giant table (5000 rows x 7 columns) in a CSV file. I would like to somehow load this table into the Django framework -- and access the values in the table.
If the table were smaller, I could create a new model, then load the CSV into the model. But instinctively, it feels wrong to create a model with thousands of fields. Is there another way to load the table into Django framework, and reference the values via something like a vlookup function?
Thank you for any assistance!
django
My background is 100% in Excel VBA. But I'm working on building some of my first web applications in Django framework. Please pardon me if this question is ridiculous.
I have a giant table (5000 rows x 7 columns) in a CSV file. I would like to somehow load this table into the Django framework -- and access the values in the table.
If the table were smaller, I could create a new model, then load the CSV into the model. But instinctively, it feels wrong to create a model with thousands of fields. Is there another way to load the table into Django framework, and reference the values via something like a vlookup function?
Thank you for any assistance!
django
django
asked Dec 28 '18 at 23:29
Mark1937Mark1937
12
12
7 columns seems very reasonable for a model. On mobile but lookup some articles on introductions to dbs. A good first one is MySQL. Then read more on Django's orm. The answer is to make a model with fields for the seven columns. Then read the csv and insert the rows through Django's orm.
– dennmat
Dec 28 '18 at 23:42
Ty Dennmat. So the columns are geographic areas (like CITY, COUNTY, STATE). But all of the rows are unique. For example, row 100 could be "POPULATION_2000" -- then in the columns it would have City population as of 2000, County population as of 2000, etc. So if I wanted to access the "Population in 2000 for the City" --- how could I "lookup" to find the correct Row/Column intersection to get the value I want?
– Mark1937
Dec 29 '18 at 0:15
You could add a Year field to the model then when querying you could do stuff like. Population.objects.filter(year=2000, city='New York') and that would give you the row(s) that match New York and the Year 2000. It's hard to answer without having a clearer view of what the CSV structure really is.
– dennmat
Dec 29 '18 at 1:02
Thank you very much. I will explore the objects.FILTER technique, and see how that goes. It seems promising.
– Mark1937
Dec 30 '18 at 21:06
add a comment |
7 columns seems very reasonable for a model. On mobile but lookup some articles on introductions to dbs. A good first one is MySQL. Then read more on Django's orm. The answer is to make a model with fields for the seven columns. Then read the csv and insert the rows through Django's orm.
– dennmat
Dec 28 '18 at 23:42
Ty Dennmat. So the columns are geographic areas (like CITY, COUNTY, STATE). But all of the rows are unique. For example, row 100 could be "POPULATION_2000" -- then in the columns it would have City population as of 2000, County population as of 2000, etc. So if I wanted to access the "Population in 2000 for the City" --- how could I "lookup" to find the correct Row/Column intersection to get the value I want?
– Mark1937
Dec 29 '18 at 0:15
You could add a Year field to the model then when querying you could do stuff like. Population.objects.filter(year=2000, city='New York') and that would give you the row(s) that match New York and the Year 2000. It's hard to answer without having a clearer view of what the CSV structure really is.
– dennmat
Dec 29 '18 at 1:02
Thank you very much. I will explore the objects.FILTER technique, and see how that goes. It seems promising.
– Mark1937
Dec 30 '18 at 21:06
7 columns seems very reasonable for a model. On mobile but lookup some articles on introductions to dbs. A good first one is MySQL. Then read more on Django's orm. The answer is to make a model with fields for the seven columns. Then read the csv and insert the rows through Django's orm.
– dennmat
Dec 28 '18 at 23:42
7 columns seems very reasonable for a model. On mobile but lookup some articles on introductions to dbs. A good first one is MySQL. Then read more on Django's orm. The answer is to make a model with fields for the seven columns. Then read the csv and insert the rows through Django's orm.
– dennmat
Dec 28 '18 at 23:42
Ty Dennmat. So the columns are geographic areas (like CITY, COUNTY, STATE). But all of the rows are unique. For example, row 100 could be "POPULATION_2000" -- then in the columns it would have City population as of 2000, County population as of 2000, etc. So if I wanted to access the "Population in 2000 for the City" --- how could I "lookup" to find the correct Row/Column intersection to get the value I want?
– Mark1937
Dec 29 '18 at 0:15
Ty Dennmat. So the columns are geographic areas (like CITY, COUNTY, STATE). But all of the rows are unique. For example, row 100 could be "POPULATION_2000" -- then in the columns it would have City population as of 2000, County population as of 2000, etc. So if I wanted to access the "Population in 2000 for the City" --- how could I "lookup" to find the correct Row/Column intersection to get the value I want?
– Mark1937
Dec 29 '18 at 0:15
You could add a Year field to the model then when querying you could do stuff like. Population.objects.filter(year=2000, city='New York') and that would give you the row(s) that match New York and the Year 2000. It's hard to answer without having a clearer view of what the CSV structure really is.
– dennmat
Dec 29 '18 at 1:02
You could add a Year field to the model then when querying you could do stuff like. Population.objects.filter(year=2000, city='New York') and that would give you the row(s) that match New York and the Year 2000. It's hard to answer without having a clearer view of what the CSV structure really is.
– dennmat
Dec 29 '18 at 1:02
Thank you very much. I will explore the objects.FILTER technique, and see how that goes. It seems promising.
– Mark1937
Dec 30 '18 at 21:06
Thank you very much. I will explore the objects.FILTER technique, and see how that goes. It seems promising.
– Mark1937
Dec 30 '18 at 21:06
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53965397%2fdjango-table-loading-data-table-accessing-values%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53965397%2fdjango-table-loading-data-table-accessing-values%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
7 columns seems very reasonable for a model. On mobile but lookup some articles on introductions to dbs. A good first one is MySQL. Then read more on Django's orm. The answer is to make a model with fields for the seven columns. Then read the csv and insert the rows through Django's orm.
– dennmat
Dec 28 '18 at 23:42
Ty Dennmat. So the columns are geographic areas (like CITY, COUNTY, STATE). But all of the rows are unique. For example, row 100 could be "POPULATION_2000" -- then in the columns it would have City population as of 2000, County population as of 2000, etc. So if I wanted to access the "Population in 2000 for the City" --- how could I "lookup" to find the correct Row/Column intersection to get the value I want?
– Mark1937
Dec 29 '18 at 0:15
You could add a Year field to the model then when querying you could do stuff like. Population.objects.filter(year=2000, city='New York') and that would give you the row(s) that match New York and the Year 2000. It's hard to answer without having a clearer view of what the CSV structure really is.
– dennmat
Dec 29 '18 at 1:02
Thank you very much. I will explore the objects.FILTER technique, and see how that goes. It seems promising.
– Mark1937
Dec 30 '18 at 21:06