+ 6

Is it a good way to store data in a .txt file?

Is it a good way to store data using .txt files? e.g. Java -> import java.io.file C++ -> include <fstream>

3rd Apr 2019, 10:13 AM
デジモン Lover
デジモン Lover - avatar
7 Antworten
+ 9
txt is one of the possible choices. But there can be ini, json, xml and other human readable formats. But you can choose not human readable, for example some binary format or your own format. For example sql localdb uses its own format. You must understand that you use disc resources, so it is not good to read and write very often. You can accumulate some buffer in memory before writing, so does logging works for example in nginx server. If you only read data, then read it once when it needs and load into memory, then just watch for date when the file was changed or some other flag or signal.
3rd Apr 2019, 12:28 PM
Владимир Землянушкин
Владимир Землянушкин - avatar
+ 11
Good question! I am interested in reading from text files from a 3rd party site to load different songs as data files. This code creates a text file in PHP from within the program and reads from it, but does not overwrite nor permanently save the file due to SoloLearn's wise security measure. https://code.sololearn.com/we7W2j7yfnAL/?ref=app https://code.sololearn.com/w5jH5849OvXl/?ref=app https://code.sololearn.com/w5I1a3fkpsb5/?ref=app
8th May 2019, 1:21 AM
boneSpider
boneSpider - avatar
+ 6
Depends on how often you'll be retrieving it and whether it is structured or not...you can use human readable formats like xml...or serialized ones or just plain text. All that depends on what you want to solve
5th Apr 2019, 5:31 AM
Dan Rhamba
Dan Rhamba - avatar
+ 3
Depends on what are you going to do with them. It could be better to se e.g. .json or .xml if you have it structured, but if you have just plain text it is no problem.
3rd Apr 2019, 11:17 AM
Maneren
Maneren - avatar
+ 3
Is it problematic to load and save a file (the same file) very often (for safety reasons)?
3rd Apr 2019, 12:43 PM
HonFu
HonFu - avatar
+ 2
Txt file extension is useful if you open this file with win default editor. Otherwise file extension is no matter for your program/project.
3rd Apr 2019, 6:40 PM
Roman Harmash
Roman Harmash - avatar
0
No... Bad idea, too open
5th Apr 2019, 5:59 AM
Glen osano
Glen osano - avatar