Один из самых удобных способов записать данные это использование готовых форматов, такие как 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
PDVSA signed two agreements with a subsidiary of Nigerian company Atlas Oranto to certify offshore natural gas reserves. Caracas has touted investment opportunities in its largely untapped gas reserves in a bid to attract foreign partners.
Read the report: https://venezuelanalysis.com/news/venezuelan-govt-strikes-natural-gas-deal-with-nigerian-corporation/
#Venezuela#NaturalGas#Sanctions
📰 NEWS | US Nixes Venezuela-Trinidad Natural Gas Licenses as Maduro Declares Economic Emergency
The Trump administration has revoked licenses that allowed Trinidad and Tobago to negotiate natural gas ventures with Venezuela. Shell and BP were also involved.
At the same time, Venezuelan President Nicolás Maduro invoked emergency powers to deal with economic instability and a global trade war.
Read our report: https://venezuelanalysis.com/news/us-nixes-venezuela-trinidad-natural-gas-licenses-as-maduro-declares-economic-emergency/
#Venezuela#Trinidad#NaturalGas#Sanctions
🌍 The largest natural gas field in the world, the South Pars/North Dome field, sits beneath the Persian Gulf and holds more recoverable gas than any other single spot on the planet. ✨
#naturalgas⚡#energy⚡#PersianGulf⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🚀 U.S. EIA Natural Gas Inventory Exceeds Expectations
The U.S. Energy Information Administration (EIA) reported that natural gas inventories for the week ending April 3 reached 50 billion cubic feet. According to Jin10, this figure surpassed the anticipated 46 billion cubic feet and the previous week's level of 36 billion cubic feet.
#USEIA#NaturalGas#Inventory#Energy#GasSupply#US
🚀 Trump Highlights Incoming Oil Tankers to the U.S.
On April 11, U.S. President Donald Trump announced on his Truth platform that numerous empty oil tankers, including some of the world's largest, are currently en route to the United States. According to BlockBeats, these tankers are carrying some of the highest quality oil and natural gas globally. Trump emphasized that the U.S. oil reserves surpass the combined reserves of the second and third largest oil-producing countries, both in quantity and quality. He invited attention to this development, urging prompt action.
#Trump#OilTankers#USOilReserves#NaturalGas#Energy#GlobalOil#TrumpAnnouncement#USPresident#BlockBeats
🚀 S&P: UK Economy Expected to Withstand Price Shocks from Middle East Conflict
S&P Global Ratings has indicated that the stable outlook for the UK economy reflects market expectations that it will be able to withstand the impact of rising prices for oil, natural gas, and other inputs related to the Middle East conflict. According to Jin10, this assessment suggests confidence in the UK's economic resilience amid geopolitical tensions affecting commodity prices. The report highlights the importance of monitoring these developments as they could influence economic stability and growth prospects.
#UKEconomy#MiddleEastConflict#OilPrices#NaturalGas#EconomicResilience#Geopolitics#EconomicStability#MarketOutlook#S&PGlobalRatings #CommodityPrices
🚀 White House Predicts Gasoline Price Drop with Hormuz Strait Opening
The White House National Economic Council Director, Kevin Hassett, has indicated that gasoline prices are expected to decrease swiftly once the Strait of Hormuz is reopened. According to Odaily, Hassett mentioned that discussions have been held with allies to ensure a stable supply of U.S. oil. Additionally, consultations regarding the purchase of oil and natural gas have been conducted with allied nations.
#WhiteHouse#GasolinePrices#HormuzStrait#OilSupply#USEconomy#EnergyPolicy#NaturalGas#KevinHassett#GlobalTrade#OilMarket
Barrell Lithium Raises $1.33M
Barrell Energy has completed a funding round of $1.33 million as of December 5, 2024. The company is focusing on various energy sectors, including oil, natural gas, and renewables such as solar and wind, alongside technology and carbon sequestration initiatives. This aligns with the global trend towards energy expansion and diversification.
#BarrellEnergy#Funding#Energy#Renewables#Solar#Wind#BatteryStorage#CarbonSequestration#Technology#BrineMinerals#Oil#NaturalGas#EnergyExpansion#Diversification
🚀 U.S. March CPI Expected to Rise Amid Ongoing Iran Conflict
The market widely anticipates that the U.S. Consumer Price Index (CPI) for March will increase by 3.4%, surpassing last month's 2.4%, marking the largest year-on-year rise in two years. According to Jin10, during past oil market shocks, the most likely commodities to see price hikes include aviation fuel, steel, aluminum, natural gas, fertilizers, and plastics. Industries reliant on these materials are already feeling the strain. The ongoing Iran conflict, which has lasted several weeks, has shifted concerns from the initial oil price surge to the compounded effects of a prolonged conflict. For many economists, the most alarming aspect is not the immediate issues but the "aftershocks" that may emerge months or even years later. JPMorgan's CEO has referred to inflation as a potential "fly in the ointment" that could undermine stock market returns in 2026. Harvard University professor and former IMF chief economist Ken Rogoff recently discussed an overlooked impact of the war: the increased military spending's effect on the already strained U.S. budget deficit. He noted the risk of soaring bond yields, which could harm the stock market and affect U.S. affordability. Rogoff also mentioned that the current supply disruptions caused by the Iran conflict are sufficient to keep oil prices elevated for a year.
#USCPI#inflation#IranConflict#oilprices#aviationfuel#steel#aluminum#naturalgas#fertilizers#plastics#economicimpact#stockmarket#JPMorgan#budgetdeficit#militaryspending#bondyields#HarvardEconomist#supplydisruptions#USaffordability