Giter Site home page Giter Site logo

Comments (23)

GhostVaibhav avatar GhostVaibhav commented on September 27, 2024 1

@htcfreek I would. But, I would take a little more time than regular devs, since it's my first time working on this module. Hope it's fine.

from powertoys.

htcfreek avatar htcfreek commented on September 27, 2024 1

@GhostVaibhav
Regarding the ToDos: We also have to update the split code to use the same regex.

And a small not about testing: You have to build the whole PowerToys solution.

from powertoys.

GhostVaibhav avatar GhostVaibhav commented on September 27, 2024 1

@htcfreek, I have no idea about this stuff, as I'm still very new. But, I think this should be a separate issue since it is no where related to this issue.

from powertoys.

htcfreek avatar htcfreek commented on September 27, 2024 1

Doesn't the issue mentioned here just revolve around the parsing?

You are true. We can do the hashtag fix thing in another PR.

If your code is ready to create a PR I suggest to open it. If the core team asks for the hashtag handling/fixing we can add it.

from powertoys.

htcfreek avatar htcfreek commented on September 27, 2024

Blocked by the rework of the parser (#33165 , #33085).

from powertoys.

htcfreek avatar htcfreek commented on September 27, 2024

Possible solution using regex:

@",(?=[^""]*(?:""[^""]*""[^""]*)*$)"

Thanks to @GhostVaibhav.

from powertoys.

GhostVaibhav avatar GhostVaibhav commented on September 27, 2024

Hi @htcfreek, if this is a small one, maybe I could help and open a PR quickly.

from powertoys.

htcfreek avatar htcfreek commented on September 27, 2024

Hi @htcfreek, if this is a small one, maybe I could help and open a PR quickly.

@GhostVaibhav
The problem here is the correct regex. We didn't figure it out yet. But your help is welcome.

from powertoys.

GhostVaibhav avatar GhostVaibhav commented on September 27, 2024
Screenshot 2024-07-07 at 6 26 27 PM

@htcfreek, I think your regex is working fine.

from powertoys.

htcfreek avatar htcfreek commented on September 27, 2024
Screenshot 2024-07-07 at 6 26 27 PM

@htcfreek, I think your regex is working fine.

@GhostVaibhav
What happened if the comma is in the first data string. I imagine that the regex os failing then.

Another thing might be escaping the " with "".

from powertoys.

GhostVaibhav avatar GhostVaibhav commented on September 27, 2024
Screenshot 2024-07-07 at 6 30 27 PM

@htcfreek For the first data string, it's passing. But for escaping with double quotes, it's failing.

Screenshot 2024-07-07 at 6 34 03 PM

from powertoys.

GhostVaibhav avatar GhostVaibhav commented on September 27, 2024

@htcfreek I think I found the exact implementation you're looking for.

https://stackoverflow.com/a/769713/12634085

from powertoys.

htcfreek avatar htcfreek commented on September 27, 2024

But for escaping with double quotes, it's failing.

Screenshot 2024-07-07 at 6 34 03 PM

The last test line is wrong. It should not end with a " or you need """ instead of "". Because your test line has a closing bot no opening " in the last data element.

from powertoys.

GhostVaibhav avatar GhostVaibhav commented on September 27, 2024

So, if we take that into consideration, it is passing.

from powertoys.

htcfreek avatar htcfreek commented on September 27, 2024

Not sure if my regex (found with copilot) is the same as yours but it seems to work:

,(?=(?:[^""]*""[^""]*"")*[^""]*$)

Screenshot_20240707-160224_Samsung Internet.jpg

We can add an additional check if the number of " can be divided by 2. => The no " is missing.

from powertoys.

GhostVaibhav avatar GhostVaibhav commented on September 27, 2024

@htcfreek all the regexes mentioned in this thread are passing all the checks.

from powertoys.

htcfreek avatar htcfreek commented on September 27, 2024

@GhostVaibhav
Do you like to work on it? Should be easy to implement:

  • Update counting code to use the regex, and only match on equal count.
  • Add check for " sign count.
  • Update logic that selects the delimiter, that it selects the one with the same count in first and second line.

The file to update is <Advanced Paste Module>/Helpers/JsonHelper.cs

from powertoys.

htcfreek avatar htcfreek commented on September 27, 2024

@GhostVaibhav
I found a way to remove/replace the quotation marks in csv code to get correct json version.

Example:

csv code: "my ""text"""
json code: my ""text""
json imported: my "text"

This requires the two following action in correct order: First remove single marks, then replace other ones.

1. remove: ^""(?!"")|(?<!"")""$|^""""$
- First and last sign if single " AND only two "

2. replace by single ": ^""{3}(?!"")|(?<!"")""{3}$|""{2}
- first three* OR last three* OR pairs of two (* if not more than three)

Do you think this should be an extra issue/pr or does it make sense to implement with escape handling?

from powertoys.

GhostVaibhav avatar GhostVaibhav commented on September 27, 2024

Hi @htcfreek, is the result ok?

image

from powertoys.

htcfreek avatar htcfreek commented on September 27, 2024

Hi @htcfreek, is the result ok?

image

@GhostVaibhav
Looks good. Can we try to add additional " handling code:

1. (RegexReplace by empty string): ^""(?!"")|(?<!"")""$|^""""$
    => Remove first and last sign if single " or empty data set like `""`.
2. (RegexReplace with single "): ^""{3}(?!"")|(?<!"")""{3}$|""{2}
    => Replace first three* OR last three* OR pairs of two. (* If not more than three)

The regex replace command need to be applied to each data element in the correct oder. The correct order would be: First replace with empty string and the replace with single ".

from powertoys.

GhostVaibhav avatar GhostVaibhav commented on September 27, 2024

@htcfreek, are you saying this in reference to the correct JSON representation or parsing of the whole string in general?

from powertoys.

htcfreek avatar htcfreek commented on September 27, 2024

@htcfreek, are you saying this in reference to the correct JSON representation or parsing of the whole string in general?

Well I think correct parsing means to not have technical/format caused to many " in the converted output.

The regex would be applied when generation the json result.

from powertoys.

GhostVaibhav avatar GhostVaibhav commented on September 27, 2024

Doesn't the issue mentioned here just revolve around the parsing?

from powertoys.

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.