GithubHelp home page GithubHelp logo

Edit parquet file about flow HOT 2 CLOSED

eerison avatar eerison commented on August 30, 2024
Edit parquet file

from flow.

Comments (2)

eerison avatar eerison commented on August 30, 2024

I was using flow-php/parquet But I just saw that, there is a saveMode on main repo.

I will check the code bellow

data_frame()
    ->read(from_parquet(__DIR__ . '/orders_flow.parquet'))
    ->select('created_at', 'total_price', 'discount')
    ->withEntry('created_at', ref('created_at')->cast('date')->dateFormat('Y/m'))
    ->withEntry('revenue', ref('total_price')->minus(ref('discount')))
    ->select('created_at', 'revenue')
    ->groupBy('created_at')
    ->aggregate(sum(ref('revenue')))
    ->sortBy(ref('created_at')->desc())
    ->withEntry('daily_revenue', ref('revenue_sum')->round(lit(2))->numberFormat(lit(2)))
    ->drop('revenue_sum')
    ->write(to_output(truncate: false))
    ->withEntry('created_at', ref('created_at')->toDate('Y/m'))
    ->saveMode(overwrite())
    ->write(to_parquet(__DIR__ . '/daily_revenue.parquet'))
    ->run();

in case it didn't work I reopen the issue :)

from flow.

norberttech avatar norberttech commented on August 30, 2024

hey @eerison
let me answer your question:

is it possible to edit the file?

No, parquet files are immutable, they can't be directly edited. Instead, if you want to modify the file, you should read it, modify it on the fly, and save it somewhere else.

The saveMode in flow is going to let you overwrite existing file, bot not modify it.

Note: in case it isn't the correct place to open this issue, could you move to the main repo please.

no worries, here is fine, you can also join ourbdiscord server where you can get your answers faster 😊 you can find link on the website header https://flow-php.com

from flow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.