So I am a PHP developer really, I have only really used MySQL and some MSSQL datbases, as well as excel back in the day.
I have a client we are building an eCommerce shop for and he wants to save on the time it would take to data-input the products table. The list is provided by another company, think wholesale.
So they have given me a CSV file. a common entry looks like this.
"MAINCAT"^"SUBCAT"^355303^"10931"^"MANUFACTURER"^"Short Description"^"sgl"^"1"^1^.00^.00^.00^.00^.00^.00^6.79^"15561109314 5015561109314"^.20^"This is where the description goes"
I havn't got much experience with CSV files, but from stuff I've looked at, it seems a strange format, and some programmes don't even recognise it as a CSV file.
I have been unable to convert it into MySQL.
My question basically is, is there a way to utilise this CSV file, that will fit in with another PHP and MySQL drive eCommerce platform. ie. can it be easily converted, or utilised as a data platform that will be efficient.
Sorry if this isn't in the right place.
This is hardly a csv file (comma separated values)
Try to convert it as you go, to match this explicit format.
Without knowing the data integrity, an example to make it CSV
$strange_lines = file('strange_csv.csv');
foreach ($strange_lines as $line) {
echo str_replace(array('"^"','^"','"^','^'),',',$line).'<br>';
}
Related
I do not know if this is the right spot to ask my question perhaps I should do it another community but I got a question regarding implementing a website that deals with a large CSV file as input.
I am willing to program a website that have a CSV file as input to generate all kinds of data on my website. Think of each entry has their own geolocations etc. In the end I want to create an informative website where the data of the CSV file is used.
Now I want to know what approach might be the best to do this. I can imagine that storing this CSV file within a Database and retrieving data with PHP might take forever due to large loading time when the website is making a call. Can anyone tell me what approach might work when working which such large CSV file?
To give you an idea. In my CSV file I have the following data:
#, Soccer Club, Street adress, Highest competition,..
1, Soccer club 1, adress 123, 3th division,..
2, Soccer club 2, adress 456, 6th division,..
etc.
Now I want to create a webste that use this data and create all kinds of marker points on a map. I do know how to code this the only problem is that I am searching for a fast way of reading and using the data without having my website to load a long time to generate this information. I did not try it yet but before I spend to much time on it I was wondering which advise could you give me?
BTW Think of CSV files of the size of 1GB/2GB
I would suggest you to import the CSV in to a database table not store the whole file as is and then run queries on it. Databases are optimised and meant for these things.
A few months ago, my supervisor needed me to create a form to collect some data - at the time, the most sensible thing to do was just to whip together a Google Form, no problem. Now it turns out that the data collection program needs to expand, and it makes more sense to direct the form to a MySQL database (using PHP) instead - again, no problem, already done. However, for reasons I won't elaborate on here, my supervisor still wants that data to go to the original Google Sheet as well.
My question - is it possible to submit form data to two separate sheets when one is a MySQL table and the other is a Google Sheet?
Thanks!
I know that feel bro ;)
There's some resources to handle boss requests:
PHPExcel Class is a library written in pure PHP and providing a set of classes that allow you to write to and read from different spreadsheet file formats, like Excel (BIFF) .xls, Excel 2007 (OfficeOpenXML) .xlsx, CSV, HTML...
You will need an script to process the outputs.
Excel / CSV > MySQL
MySQL > Excel / CSV
If you need directly to work with Google Docs, you will have to follow the previous steps and play with the following project:
php-google-spreadsheet-client is a library that provides a simple interface to the Google Spreadsheet API.
You will need to store data in MySQL and pass it to Google.
Second idea:
If your boss neet it NOW, you can give a chance to Zapier and do it fast. If you don't need a very fast sync time, it can be a good free option.
I hope it helps :)
Very sorry if this is not in the right place etc. I have been researching this for a while but its raised more questions!
I have developed a spreadsheet which I use to set a teams duties for a shift. There are 5 teams, each with staff which can change day to day.
the spreadsheet works fine, but its too complicated for some users. I am therefore trying to develop a straightforward web based form.
All the data is on the spreadsheet, held on a network drive (essentially locally).
I need to be able to have several combo/select boxes which get their values from a range of cells from the XLS. Along with the ability to output the final selections to a XLS sheet.
Finally, it needs to be able to load the previous day values on load.
What is the best way of developing a web page for this? Is Jscript the best option? Can I access a local file with jScript?
Thanks in advance
Adrian
The easiest option for you is to use google web forms. These allow creation of forms that will submit data to a google spreadsheet. Which is essentially an uploaded version of your local spreadsheet and can be downloaded to excel.
In case if you want more control and programming, pure javascript cant play with files, you need server side too. Javascript is not necessary unless you want to make your app do some visually fancy stuff. Since you mentioned php as a tag of this question, it seems you are a bit familiar with php. The task you have mentioned can be done using php programming as below:
Read excel file using an excel plugin
Parse relevant data using a text matching function, may require regular expressions knowledge.
display the form by building up the html and putting in the variables using the data obtained above.
Write a method to save the data submitted by the form to the same excel file using the excel plugin.
As its not convenient to play around with excel files. A better option would be to generate csv file or use a database using a database class . csv files can be parsed easily using text.
I've currently got a database with just short of 2000 client locations in Australia. What I am trying to do is to display this data on a heatmap, to be embedded into an existing website.
I've done a heap of looking around, and can't seem to find exactly what I'm after.
http://www.heatmapapi.com/sample_googlev3.aspx
http://www.heatmaptool.com/documentation.php
These are along the right lines of what I want to achieve, however I cannot see these working with data from a mysql database (require the data to be hard-coded, or uploaded through CSV files).
Has anyone come across this sort of thing before, or managed to achieve it?
Both of the examples you provide would potentially work.
With the first you would need to use the data you have to dynamically generate the javascript, or at least the values that go into the javascript.
The second is probably the better option. You would provide a path to the script that would dynamically generate a CSV file.
I know the title isn't the most descriptive, but I can't think of a better way to describe it.
Ultimately what I would like to do is this:
I am making a system that handles import of data via CSV from several different companies. Naturally, the format from each company is slightly different, with different amounts of data in each column/heading and a different arrangement.
I could either:
Hard code the file format into the program, which is quick and simple to program, but not abstract or future proof
or provide "dynamicity" by allowing users to configure "file formats" in the system, by dragging and dropping CSV headings and saving presets for each incoming file format.
I would like to do option 2, but how would I go about doing this?
I am guessing a tagging style system would do it... but any advice would be appreciated.
I am using PHP, MySQL, and CodeIgniter 2.0.2 if that helps, and also have access to all the Zend libraries in my app.
Assuming that users will be submitting a subset of possible data types that you define up front, this shouldn't be too tough.
A simple form that allows the user to select the data type and give you the field name in their csv could be used to create the templates you mentioned. Store these in a database table associated with the user and make them choose a template before importing a csv. For customers who have csvs without header rows, a slight variation where they tell you the column numbers for each data type.
I'd also suggest providing pre-defined formats for customers who haven't defined their exports yet. That way they could build their exports to one of your formats.
You could also let users define their default template. That way they wouldn't have to select the template every time they import data if they're always importing data in the same format.