Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
Bacterial meningitis leaves 1 in 5 people with disabilities such as hearing loss, brain damage and limb loss.
But meningitis is largely vaccine-preventable!
Parents/caregivers are urged to visit any primary health care centre to get their children/wards vaccinated against #meningitis.
Your input is crucial in shaping better prevention, treatment and control strategies against #Meningitis in Nigeria.
📋Take our #Meningitis KAP Survey to share your knowledge, attitudes, and practices.
🔗Survey link
https://forms.gle/R5uxSdet2nPNQvpRA
#Meningitis spreads mostly from one person to another through respiratory droplets e.g. coughing, sneezing & close contact such as kissing
Meningitis can affect anyone at any age.
Seek medical attention if you experience symptoms.
#Meningitis is a serious infection that can lead to severe complications & death
Report immediately to a healthcare facility if you or a loved one experiences
➡️Neck pain
➡️Pain on looking at bright lights
➡️Vomiting
➡️Muscle/joint/limb pain
➡️Rash
➡️Seizures
➡️Cold hands & feet
#Meningitis vaccines are safe, effective, and give protection to your family and community.
Parents and caregivers, now is the time to catch up on the childhood immunisations that protect against meningitis.
Any form of #Meningitis is an emergency!
ALL healthcare workers are urged to have a high index of suspicion and immediately report if they notice these signs & symptoms in their patients:
➡️Fever/severe headache
➡️Vomiting
➡️Drowsiness
➡️Rash
➡️Seizures
➡️Muscle/joint pain
➡️Stiff neck
The spread of #meningitis is usually through:
➡️ Direct person-to-person contact, including droplets from the nose and throat of infected persons.
➡️Close and prolonged contact with an infected individual.
Visit the nearest health facility immediately if you notice any of the CSM-associated signs and symptoms.
#Meningitis is an inflammation of a thin layer of the connective tissue that covers the brain and the spinal cord.
This inflammation can be caused by infection with bacteria, viruses, parasites, fungi, injuries and certain drugs.
Know the symptoms to seek early health care.
Advisory:
https://ncdc.gov.ng/news/508/cerebrospinal-meningitis-public-health-advisory
#Meningitis is an epidemic-prone disease requiring immediate reporting in Nigeria.
ALL healthcare workers are urged to have a high index of suspicion if they notice these signs & symptoms in their patients:
➡️Fever/severe headache
➡️Vomiting
➡️Drowsiness
➡️Rash
➡️Seizures
➡️Muscle/joint pain
➡️Stiff neck
Bacterial meningitis is largely vaccine-preventable; #meningitis vaccines are safe, effective, and give protection to your family and community.
Parents and caregivers, now is the time to catch up on the childhood immunisations that protect against meningitis.
Hand washing is one of the most effective ways of preventing the spread of infectious diseases including #meningitis
Always wash your hands with soap under running water for protection against meningitis and other deadly diseases
Also ensure you and your loved ones are vaccinated with the recommended immunisations
Report immediately to a healthcare facility if you or a loved one experiences the below symptoms of #Meningitis
➡️Neck pain
➡️Pain on looking at bright lights
➡️Vomiting
➡️Muscle/joint/limb pain
➡️Rash
➡️Seizures
➡️Cold hands & feet
Early recognition saves lives