OpenCart Wishlist - opencart

I'm trying to parse out the wishlist column in open cart's wishlist_to_store column to retrieve the product ID's. At first glance I thought it was being stored as JSON, but that obviously not the case. Is there a library or method I can use to parse it out?
Example wishlist:
a:2:{i:0;s:5:"16419";i:1;s:5:"16415";}

The method you are looking to use is called unserialize(). This is fairly similar in function to what JSON does but is the PHP equivalent. You can use it as follows
$a = unserialize('a:2:{i:0;s:5:"16419";i:1;s:5:"16415";}');
var_dump($a);

Related

Data validation for time input in Google Sheets

I am searching for a solution that would allow users to insert time values only in this format: hh:mm, and reject if something else is inserted. Something similar like data validation for date - Data validation -> Is valid date -> Reject input.
I tried to search and adjust a Regexmatch formula for this one, with no success, but I am open for other suggestions also.
Thank you in advance!
SUGGESTION
Perhaps you can try using a more specific regex such as the one sample from this existing post. Then, apply it your data validation via a custom function using REGEXMATCH function as seen here:
=REGEXMATCH(TO_TEXT(A1),"^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$")
Sample Data Validation Config:
Demo:
E.g. Any text or date formats won't be accepted.
use custom formula:
=REGEXMATCH(""&A1; "\d{2}:\d{2}")
if you want to block inputs like: 75:99 then try:
=REGEXMATCH(""&A1; "\d{2}:\d{2}")*((A1*1)<=1)

How to capture dynamic value in regular expression which depend on another dynamic value

I am new to Jmeter and I am looking for a way of capturing bolded "id" ("id":"56fa091ae4b081fb934b083a") which is having a dynamic data based on the "parentEventId" which is also a dynamic value in metadata section (I already have the "parentEventId" value taken from previous thread group). There can be multiple records with different "parentEventId"s and I need to get the mentioned "id" data of a selected "parentEventId".
This might have a simple answer but I couldn't find expression to use in If Controller and I have tried several RegEx extractors none of them worked and I couldn't find any positive answer for my question in web as well.
So any help on this would be highly appreciated, Thank you in advance
Below is my Body Data;
[{"id":"56fa091ae4b081fb934b083a","eventCalendar":{"id":"53757a6c156695a10bcefd57","type":"PERSON","displayName":"Test Name"},"organizerEvent":true,"start":1459486061505,"end":1459489661505,"allDay":false,"title":"test title","description":"test description","location":"test location","className":"cs-12","type":"CALENDAR","visibleToPublic":false,"metadata":{"parentEventId":"56fa091ae4b081fb934b0839"},
If your parentEventId and id are equal - why just not to use parentEventId? If not - update your question with full response and show relationships.
By the way, it's better to us JSON Path Extractor available via JMeter Plugins project for working with JSON Data, it's much more handy than regular expressions. For instance, you can extract parentEventId with something like:
$..parentEventId[0]
References:
JSON Path - XPath for JSON
Using the XPath Extractor in JMeter (scroll down to Parsing JSON)
If i understand correctly you are supplied with a dynamic parentEventId information and you would like to extract the child id from JSON data accordingly. If this is the case the following might be your solution
var parentEventId = "56fa091ae4b081fb934b0839",
data = '[{"id":"56fa091ae4b081fb934b083a","eventCalendar":{"id":"53757a6c156695a10bcefd57","type":"PERSON","displayName":"Test Name"},"organizerEvent":true,"start":1459486061505,"end":1459489661505,"allDay":false,"title":"test title","description":"test 56fa091ae4b081fb934b083adescription","location":"test location","className":"cs-12","type":"CALENDAR","visibleToPublic":false,"metadata":{"parentEventId":"56fa091ae4b081fb934b0839"},',
rex = new RegExp('\\[{"id":"([a-f0-9]{24})"(?=.*{"parentEventId":"' + parentEventId + '"})',"g"),
res = rex.exec(data);
console.log(res[1]); // 56fa091ae4b081fb934b083a

How to query mongodb with a regex in the projection?

Does anyone know if there is a way to query MongoDB and have only certain fields returned by using a regex as part of the projection?
For example: Given a collection having arbitrary field names, how might I query the collection and only return field names matching the regex '^foo'.
Possibly something like this?
db.mycollection.find({},{$regex:"^foo"})
Thanks.
Brent.
I think you need to break down the process into two pieces, the first one is retrieving the fields names from MongoDB.
Then the second piece is that you can run the regex on the result, and from there you can query the DB with the right fields.

RegEx for a JSON string

Im storing a person object as JSON in my SQLite database. The table will have few 1000 records of person objects. What i need is to query person based on the "name" attribute.
After investigation i figured out using GLOB method of SQLite to perform a RegEx kind of search in the JSON elements.
My Sample JSON is something like this.
{"name":"john","age":"22","father-name":"jackson"}
Now i want a RegEx matcher to get me all the records that matches a part of the SubString provided with the name attribute in JSON. And it should be case insensitive too.
For Ex: "ohn" search should fetch me john's record.
While you can store JSON and search against it using regexes (which are rather limited in SQLite), it does not mean you should.
Instead, you should really consider splitting your JSON into fields and storing them in normal SQLite table. Doing so will not only allow you to perform easier searches without need to painfully parse data every single time, search will be much faster too (if you add necessary indexes).
If you do want to go down the regex route the following will extract the record:
/\{"name":"\w*ohn\w*[^\}]+\}/i
This will match each of these:
{"name":"john","age":"22","father-name":"jackson"}
{"name":"john","age":"22","father-name":"johnson"}
{"name":"johnny","age":"22","father-name":"smith"}
but not:
{"name":"fred","age":"22","father-name":"hall"},
{"name":"mike","age":"22","father-name":"johnson"}
{"name":"bob","age":"22","father-name":"todd"}

Django Spreadsheet Application

I am in the making of a Django application where you will be able to upload an excel spreadsheet file and have it inserted into the application. But I sorta got the importing sorted out.
What I need is a way to store the values dynamically, I basicly need X number of fields for each row, with each three possible types.
These would be:
Boolean
String
Number
How would I go about doing so?
Let's say I have some models that contains this information:
A spreadsheet with a name, and some "header"-cells that will indidate which fields (and their name) that belong to that spreadsheet (but dynamically expanding).
A row that can have multiple cells, each with a type of either a boolean, a string or a number.
An example could be like this:
Spreadsheet 100
name (string)
city (string)
religious? (boolean)
phonenumber (number)
and then I need to pair the cells underneath with the appropiate header, like this:
row
name = "Bob Curious"
city = "New York"
religious = "Yes"
phonenumber = "888 888 888"
I hope that explains it good enough, if not, please go ahead and ask for anything you might like explained.
Thanks in advance! :)
This post is pretty old so I'm not sure whether you still need help with your issue, but I've found xlrd to be an excellent tool for scraping spreadsheet data. I would suggest investigating this package further.
Maybe others would like to hear more about the solution for this question. My plugin django-excel would help with excel data import into and export from one or more django models. What's more, the plugin provides one programming interface to handle data in ods(using odfpy or ezodf), xls(using xlrd), xlsx(using openpyxl) and csv formats. I hope it may help you.