Giter VIP home page Giter VIP logo

Comments (10)

bodiam avatar bodiam commented on September 25, 2024 1

Shouldn’t that be lower s and no trailing space?

He's passing an argument to the next method.

from datafaker.

kingthorin avatar kingthorin commented on September 25, 2024

EmployeeId','#{SequenceNumber.next ‘

Shouldn’t that be lower s and no trailing space?

from datafaker.

kingthorin avatar kingthorin commented on September 25, 2024

🤷‍♂️ I could be totally wrong, I haven’t used this part of the lib yet.

from datafaker.

bodiam avatar bodiam commented on September 25, 2024

Hi @ako , I think you're using the wrong faker. In your example, you are using Faker, but you should register the custom Provider at your own Faker. If you then do:

        BugFaker faker = new BugFaker();
        String data = faker.expression("#{csv ';','\"','true','10','EmployeeId','#{Insect.nextInsectName}','Firstname','#{Name.first_name}','Lastname','#{Name.last_name}'}");
        System.out.println(data);

This seems to work. You can find the code I've used to reproduce it here:

https://github.com/datafaker-net/datafaker/tree/custom_csv_provider/src/test/java/net/datafaker/providers/base/bug
(sorry, it's a bit sloppy, but I hope it's clear enough)

This is mostly based on the documentation here:
https://www.datafaker.net/documentation/custom-providers/

If the above works for you, and you're willing to make the documentation more clear, that would be very appreciated!

from datafaker.

snuyanzin avatar snuyanzin commented on September 25, 2024

@ako
regarding

Goal is to enable my users to generate fake csv files with 100s of records for import into database tables using the expressions, so no need to do custom java coding for csv generation. The tables expect unique id values to identify the records.

have you looked at https://github.com/datafaker-net/datafaker-gen which could do what you've described without coding (only conf files)

from datafaker.

ako avatar ako commented on September 25, 2024

@bodiam Thanks, your suggestion to instantiate the sequence number Faker works, but i wonder how this is supposed to work if you have multiple custom providers?

from datafaker.

snuyanzin avatar snuyanzin commented on September 25, 2024

in case of multiple custom provider you can register all under custom faker
e.g.

public class BugFaker extends Faker {
    public BugProvider insect() {
        return getProvider(BugProvider.class, BugProvider::new, this);
    }
}

there will be more than just one insect method.

from datafaker.

bodiam avatar bodiam commented on September 25, 2024

how this is supposed to work if you have multiple custom providers?

The BugFaker is the entry point for all the custom generations. It should be called MyCompanyCustomFaker or so, where you can register a provider for Insects, Sequence Numbers, Tire sizes, etc, and in your code, instead of using Faker, you use your own subclass everywhere.

from datafaker.

snuyanzin avatar snuyanzin commented on September 25, 2024

#869
this should simplify current approach

from datafaker.

bodiam avatar bodiam commented on September 25, 2024

Hi @ako , I assume this issue is addressed, but feel free to reopen if it's not.

from datafaker.

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.