Один из самых удобных способов записать данные это использование готовых форматов, такие как JSON или YAML.
Из плюсов такого подхода стоит отметить вот что:
🔸 готовый, повсеместно используемый и поддерживаемый формат
🔸 простой и понятный файл, удобочитаемый для человека
🔸 можно легко редактировать в любом текстовом редакторе без специальных программ и библиотек
Но есть и минусы
🔹 затраты времени при записи файла (кодирование данных в нужный формат строки)
🔹 затраты времени при чтении файла (декодирование данных в Python объекты)
🔹 размер файла увеличивается из-за разметки данных (скобки, запятые, переносы, отступы...)
🔹 перед записью все данные должны быть помещены в память в полном объёме (не всегда)
🔹 при чтении необходимо считать весь файл в память и только потом декодировать данные
Если нужно писать немного данных в несколько файлов, то затраты по времени не ощутимы. Обычно это файлы конфига или какие-либо метаданные. Это отличный вариант под такие задачи.
Есть и другой поход к записи файлов - это бинарные файлы. Используется, когда данных достаточно много и никто их не собирается читать глазками😳.
🔸 очень быстрая запись
🔸 чтение значительно быстрей чем JSON, YAML итд
🔸 размер файла значительно меньше, так как нет разметки
🔸 можно записывать данные по мере поступления не загружая всё в память
🔸 можно извлечь любую часть данных независимо
Из минусов
🔹 нужно определить свой формат записи данных (если не используете готовую спецификацию определённого формата)
🔹 не получится открыть файл и визуально понять что там записано, а для чтения файла потребуется знать его спецификацию.
🔹 не так-то просто создать такой файл без специальной библиотеки
В таком виде удобно записывать большой массив любых однородных данных. Например, мониторинг валютной биржи или кэшированная анимация 3D геометрии.
(Это не означает что нельзя записать данные разного типа, просто это будет не так удобно)
Представьте себе JPG-картинку. По сути это немного мета-информации и большой массив пикселей. Тоже самое со звуком или видео файлом. Поэтому, если вы попробуете открыть картинку в текстовом редакторе вы увидите что-то вроде такого
f15d cd29 a564 4578 ...
09e2 9bc4 a696 1253 ...
84e9 4de1 3b23 c24a ...
2534 5161 28e0 709d ...
...
Это и есть записанные байтики. И для их чтения требуется определённый софт который знает что с ними делать. Под каждый тип файла.
К чему это я? Читайте в следующем посте...
#tricks#basic
🐈⬛Мы возвращаемся к вам с итогами третьей недели рубрики Q&A
🔢 Появились ли новые тенденции в исследованиях с появлением ИИ?
🔢 Может ли искусственный интеллект самостоятельно провести исследование?
🔢 Какие существуют этические нормы по использованию ИИ?
🐈⬛ На эти и другие ваши вопросы по теме «Влияние искусственного интеллекта на научную сферу журналистики и медиаисследований» ответила заведующая кафедрой цифровых медиакоммуникаций Камилла Ренатовна Нигматуллина
🐈⬛ Завтра мы вернемся с анонсом следующего гостя, а пока предлагаем вам ознакомиться с ответами эксперта
#QnA
❗️❗️❗️Dear subscribers,❗️❗️❗️ please join us for a livestream on Friday, 19 July, at 8pm GMT!
Our friend Alex at UkraineWarTruth
had his YouTube channel banned after he published the video he made in Mariupol
The banned channel was instrumental in the great work Alex has been doing since 2014, bringing the truth about the Donbass to the people in the West. It had hundreds of thousands of views and thousands of subscribers, and it was taken down without a warning after posting three new videos, which were first-hand eye-witness accounts and which didn't break a single YouTube rule.
Please join us in supporting Alex's work by watching his latest video and subscribing to his Telegram channel: https://t.me/Ukraine_War_Truth
❗️We'd also like to invite you to our upcoming livestream on Friday, 19 July, at 8pm GMT, where Alex will join #TheBelgorodBrit to speak about Mariupol, Belgorod, Russia, Ukraine... and the freedom of speech, of course!
Please post any questions or comments in this thread.
#QnA
#stream
📱InfoDefenseENGLISH
📱InfoDefense
❗️❗️❗️Dear subscribers,❗️❗️❗️ please join us for a livestream on Friday, 19 July, at 8pm GMT!
Our friend Alex at UkraineWarTruth
had his YouTube channel banned after he published the video he made in Mariupol
The banned channel was instrumental in the great work Alex has been doing since 2014, bringing the truth about the Donbass to the people in the West. It had hundreds of thousands of views and thousands of subscribers, and it was taken down without a warning after posting three new videos, which were first-hand eye-witness accounts and which didn't break a single YouTube rule.
Please join us in supporting Alex's work by watching his latest video and subscribing to his Telegram channel: https://t.me/Ukraine_War_Truth
❗️We'd also like to invite you to our upcoming livestream on Friday, 19 July, at 8pm GMT, where Alex will join #TheBelgorodBrit to speak about Mariupol, Belgorod, Russia, Ukraine... and the freedom of speech, of course!
Please post any questions or comments in this thread.
#QnA
#stream
📱InfoDefenseENGLISH
📱InfoDefense
Qatar News Agency
Kazakh Vice Minister of Culture, Sports: Close Relations Between #Kazakhstan and #Qatar, Large Cooperation Projects Await Both Sides.
Chairman of the Management Board of JSC National Company “Kazakh Tourism” to #QNA: After HH the Amir's visit, we hope to establish great cooperation between #Kazakhstan and #Qatar, especially in the field of tourism.
Daily Questions-Answers, Facts, Idioms, Riddles and Quotes
#QnA
1. The pollutants which move downward with percolating groundwater are called
Ans . Leachates
2. Hasdo Valley in Chhattisgarh is famous for
Ans . Coal mines
3. Special Theory of Relative was proposed in
Ans . 1905
Via @askmenow
--------------------------------
#DidYouKnow
Eiffel Tower is six inches taller in summer due to 'Thermal Expansion'
#Idiom
"A hot potato"
What it means?Check Answer
#Riddle
"Where does today come before yesterday'
What is it?Check Answer
#Quote
"Optimism is a happiness magnet. If you stay positive, good things and good people will be drawn to you."
~ Mary Lou Retton
-----------------------------
Partnership with:Be Like Bro, sarcasticLOL, News Clips, Word Coach, Quiz MCQ, Ask Me Idiom & Ask Me Riddle
Daily Questions-Answers, Facts, Idioms, Riddles and Quotes
#QnA
1. Celsius and Fahrenheit show the same temperature at
Ans . 40
2. Exchange particle in Quark-Quark Interaction
Ans . Gluon
3. The working of a rockets based on the principle of:
Ans . Conservation of momentum
Via @askmenow
--------------------------------
#DidYouKnow
There are ice caves in Iceland that have hot springs.
#Idiom
"Letting the cat out of the bag"
What it means?Check Answer
#Riddle
"What has words, but never speaks"
What is it?Check Answer
#Quote
"Two roads diverged in a wood and I took the one less traveled by, and that made all the difference."
~ Robert Frost
-----------------------------
Partnership with:Be Like Bro, sarcasticLOL, News Clips, Word Coach, Quiz MCQ, Ask Me Idiom & Ask Me Riddle
Daily Questions-Answers, Facts, Idioms, Riddles and Quotes
#QnA
1. In Computer, what is the full form of UPS?
Ans . UPS = Uninterruptable Power Supply
2. Which city is built on more than 100 islands?
Ans . Venice
3. Name of vegetable which is also known as a flower?
Ans . Broccoli
4. Highest electrical conductivity found in which element?
Ans . Silver
5. Thermometer made first by?
Ans . Gauss
Via @askmenow
--------------------------------
#DidYouKnow
Lions have been observed to rest for a major part of the day, usually around 20 hours.
#Idiom
"A blessing in disguise"
What it means?Check Answer
#Riddle
"What can you hold in your left hand but not in your right"
What is it?Check Answer
#Quote
"Circumstances are beyond the control of man, but his conduct is in his own power."~Benjamin Disraeli
-----------------------------
Partnership with:Be Like Bro, sarcasticLOL, News Clips, Word Coach, Ask Me Idiom & Ask Me Riddle
Daily Questions-Answers, Facts, Idioms, Riddles and Quotes
#QnA
1. White Revolution’ is related to what?
Ans . Milk Production
2. A very successful invention ‘Liquid Oxygen’ discovered by whom?
Ans . Dewar
3. What is the radiant energy of the sun is transmitted?
Ans . Short waves
4. What is the chemical formula of ‘Sodium Hydroxide’?
Ans . NAOH
5. The Folded Earth book was written by?
Ans . Anuradha Roy
6. Barometer was invented by?
Ans . F. Banting
7. Which rays is very helpful in Long distance photography?
Ans . Infra-Red rays
Via @askmenow
____________________
____________________
#DidYouKnow
Grasshoppers have ears in their bellies
#Idiom
"A bird in the hand is worth two in the bush"
What it means?Check Answer
#Riddle
I’m light as a feather, yet the strongest person can’t hold me for five minutes.
What am I?Check Answer
#Quote
"If you spend your whole life waiting for the storm, you'll never enjoy the sunshine." ~ Morris West