[NFBCS] C++ Query: Databases and CSV Files

Nathaniel Schmidt schmidty2244 at gmail.com
Mon Sep 14 02:11:36 UTC 2020


Hi Tyler,

RE your first query: I was referring to the process of updating data by appending new data cases to an already-existing file, which I assumed would involve a certain amount of reading to an extent in order to ensure that no existing data had been overridden or tampered with in any way.

I'll take your other suggestions into consideration.  Thanks for these.

Kind regards,

Nathaniel

========================================
Nathaniel Schmidt
Undergraduate student
Bachelor of Computer Science (S306)
School of Information Technology
Faculty of Science, Engineering and Built Environment
Deakin University, Cloud campus
https://sync.deakin.edu.au/profiles/student/njschmidt/

Std. ID: 220493627
E: njschmidt at deakin.edu.au
M: 0439591709
LinkedIn: https://www.linkedin.com/in/njsch/
GitHub: https://github.com/njsch/
Skype: nathaniel_schmidt1994

> -----Original Message-----
> From: Littlefield, Tyler <tyler at tysdomain.com>
> Sent: Monday, 14 September 2020 11:15 AM
> To: NFB in Computer Science Mailing List <nfbcs at nfbnet.org>
> Cc: Nathaniel Schmidt <schmidty2244 at gmail.com>
> Subject: Re: [NFBCS] C++ Query: Databases and CSV Files
> 
> Hello:
> 
> I'm not totally sure what you're talking about in terms of being able to
> write while you read.
> 
> If you simply read the database and construct your representation of it,
> then you can essentially apend rows as you wish.
> 
> I would use something like a list if you plan on doing lots of
> insertions and deletions that are not at the beginning or end.
> 
> Your rows, as can be another data structure containing the values.
> 
> So the way I would organize this:
> 
> Create a table class (or structure if you're making this procedural).
> 
> The structure would hold the file name, the file pointer if you keep it
> open, any other data (you could store a dirty flag once a row is added,
> removed, or updated) to tell you if you need to write.
> 
> I would use an std::list for your rows.
> 
> 
> For the row class or structure:
> 
> If you know how many columns you will have and the dataset is uniform
> and not jaggid, it would almost make sense to create your own array of
> columns and not use a vector or list.
> 
> Store the column count as well, so that you will always have a stop
> point for any loops rather than having to recalculate the size of your
> array. You can use std::array for this.
> 
> If the data can all be stored as strings, you can use std::wstring. It
> is compatible with std::string in that they have the same interface, so
> while you won't be able to load a wstring into a basic string, you can
> go the other way. This also means that if you start out using
> std::string, you can easily upgrade.
> 
> If you think this may be a possibility, consider using a typedef:
> 
> typedef std::string internal_string;
> 
> That way you can simply update that to be wstring in the future.
> 
> If the data can not all be stored as strings (you'll have other types
> such as ints or floats), you can use what's called a variant: a datatype
> that can take multiple values and return the value it encapsulates. This
> would let you wrap up the variable contents and type in a structure and
> mean that the rows can contain variants. This also lets you extend the
> types your database can work with.
> 
> 
> HTh somewhat,
> 
> On 9/13/2020 7:39 PM, Nathaniel Schmidt via NFBCS wrote:
> > Hi all,
> >
> >
> >
> > I am emailing about a query that is somewhat related to a programming
> > assignment I am working on at uni for an intro to programming subject,
> > written in C++.  So I am more looking for ideas than syntax, as I need to
> > demonstrate the latter myself so as to not become liable for collusion /
> > outsourcing.
> >
> >
> >
> > The main aim of the distinction-level assessment being worked on is to
> > utilise the procedural programming paradigm, to create a primitive database
> > solution that will be able to collect data via console user input, writing
> > the data to and reading it from a CSV file.  The problem I have is one that
> > was predicted by my tutor, Ben Philip, namely that I am unsure how to
> > reliably update the created content in such a way as to be able to dump it
> > back into the file without running the risk of losing some of the previous
> > content.  So to be strictly accurate, hopefully not evaluating things at
> > face value too much, I believe the initial problem is more related to
> > reading than writing.
> >
> >
> >
> > The only superficially viable solution that immediately springs to mind is
> > to try and load the file as a multi-dimensional dynamic array of
> > primitive-typed characters, which would theoretically allow me to interact
> > with the textual content as rows (cases) of data, and columns (as in
> > characters on each line of text, not columns in the data table).  But even a
> > basic Google search informs me that this could be difficult and unreliable,
> > since updating one dimension in accustom type such as a  vector would mean
> > updating every other dimension every single time.  Furthermore, I am unsure
> > as to whether this would limit me to working with ASCII-encoded plain text
> > files, or whether I could work with anything else.  Is the latter issue not
> > necessarily a concern, or should I use a wide character type (wchar_t) to
> > represent the data, so as to (hopefully) extend my solution to being able to
> > work with UTF-8 encoded files?
> >
> >
> >
> > I'm still kind of in the design phase and have not yet written any code.
> > But the trimester is really starting to slip away so because I am keeping up
> > with most of the other content in this subject, I am now prioritising this
> > assessment to hopefully be able to obtain a higher unit grade if I can.  It
> > is, at the very least, a convention; and if not, at the very most a
> > requirement of the unit I am studying that the student should fairly
> > extensively make use of Deakin University's cross-platform, all-purpose
> > beginner's SDK, namely Splashkit <https://www.splashkit.io/> , for most of
> > their work.  So I think I can use the standard library to an certain extent
> > but Splashkit is to be the foundation of my work.
> >
> >
> >
> > Would appreciate any suggestions any of you may have.
> >
> >
> >
> > Kind regards,
> >
> >
> >
> > Nathaniel
> >
> >
> >
> >
> >
> > ========================================
> >
> > Nathaniel Schmidt
> >
> > Undergraduate student
> >
> > Bachelor of Computer Science (S306)
> >
> > School of Information Technology
> >
> > Faculty of Science, Engineering and Built Environment
> >
> > Deakin University, Cloud campus
> >
> > https://sync.deakin.edu.au/profiles/student/njschmidt/
> >
> >
> >
> > Std. ID: 220493627
> >
> > E: njschmidt at deakin.edu.au <mailto:njschmidt at deakin.edu.au>
> >
> > M: 0439591709
> >
> > LinkedIn: https://www.linkedin.com/in/njsch/
> >
> > GitHub: https://github.com/njsch/
> >
> > Skype: nathaniel_schmidt1994
> >
> >
> >
> > _______________________________________________
> > NFBCS mailing list
> > NFBCS at nfbnet.org
> > http://nfbnet.org/mailman/listinfo/nfbcs_nfbnet.org
> > To unsubscribe, change your list options or get your account info for NFBCS:
> >
> http://nfbnet.org/mailman/options/nfbcs_nfbnet.org/tyler%40tysdomain.com




More information about the NFBCS mailing list