Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Reading Excel To MySql Or Comma Delimited ...


right direction on how to deal with an xls
flie.

but the only other file I have to work
with is pdf.

I'm not sure, is xls the better of two evils?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Comma Delimited File
I am trying to read comma delimited rows of text. The problem is that
some fields may be encapsulated in "" - particularly the text fields but
not numeric fields.

Is there a simple efficient way to parse the fields with comma but also
strip off the "" encapsulating some of the fields with php?

The problem is the "" encapsulation is optional. Some fields will have
it, some won't.

Comma Delimited Csv Has Commas Inside Fields
I need to import a CSV file into a database daily. That operation in itself is simple enough but the trouble is that some fields are quoted because they have commas inside them. How do I handle this with my import script?

It would be much better if the CSV was created with all fields quoted or used a different delimited but sadly that is not an option.

Regular Expression For Comma-delimited Pairs
I have a textarea form field for inputting (or pasting) pairs of data.

I need a regular expression pattern to validate each line for the following

double quote
number
double quote
comma
double quote
alpha string
double quote
carriage return

The following comes close, but doesn't check for a carriage return at the
end of each line:

^"([0-9]?)+"([,]s?"([A-Za-z0-9]+)")*$

For example the following would return true:

"1","John"
"2","Paul"
"3","George"
"4","Ringo"

Stripping Quotes Out Of A Comma Delimited File?
I have a flat file that I'm trying to stick into a MySQL database. One
record per line, multiple fields per record, and many of them are null
fields which are just double quotes without a space between. It's probably
nothing really major for people who have done this before, but I'm a bit
stumped. The file is comma delimited. Every field is surrounded by double
quotes. I've done quite a bit of searching, on the php site and elsewhere,
but I can't seem to get it to strip the quotes out so I can explode the file
line by line to grab the fields.

Easy Comma-delimited List To Dropdown Box Converter
I was working on a simple converter when I realized that by not setting the id param of the option tag, it wasn't going to send the value of the dropdown box to my php script. I had this to start with: Code:

Reading Tab Delimited File Into Database
I have a .tab file that I need to write to the database. I've read it in, but for some reason it's not reading correctly. I'm truncating the complete database and then reloading it with whatever is in the tab file. I keep getting an error when trying to run my current code which is: Code:

Reading Excel Files Using PHP
Could someone pls give me pointers (or examples) on how to use PHP
(installed on a linux) to read & write MS Excel spreadsheets. So far
I've been converting a spreadsheet to text (as tab separated values)
and processing the text file. I'm wondering if I can avoid this step
and process the .xls file directly.

I found a thread in this group - related to this topic - but it says,
MS excel needs to be installed on target machine to use PHP's COM. I
assume he's talking about PHP running on windows target machine. How
can I use a similar approach on linux machine?

http://groups.google.com/group/comp...300071ba2b4434e

Reading A Particular Record From Excel Spreadsheet
I would like to read a particular record from excel spreadsheet.
For Example:A Shopping Cart.The data in database and excel sheet are
same,but if a user clicks on a particular product say productid:23456
then he can only see that data from excel spreadsheet,though there are
other records but no need to show other records. If anyone knows the solution for this please pm me or reply to this message.

Reading EXCEL (XLS) Documents With Other Charactersets
(the other code i cannot post due weird carakters!)

I've been searching over the internet for days but havent found why! i've tried alot of scripts (both free or wich i need to pay for) but only a pricy script (like 80$) would show the carakters in ROW C correctly. If i convert the script to a HTML document i get the carakters with &# and a four digit number... that's what i like to extract from the excel sheet.

The script i wrote is.

Code:
<?php
$excel = new COM("excel.application") or die("Unable to instanciate excel");

//bring it to front
$excel->Visible = 1;//NOT
//dont want alerts ... run silent
$excel->DisplayAlerts = 1;

//open document
$excel->Workbooks->Open("d:/excel.xls");

for ($h = 1; $h <= 3; $h++)
{
$book = $excel->Workbooks(1);
$sheet = $book->Worksheets($h);

echo "<table>
";
//Wtite row
for ($i = 1; $i <= 150; $i++)
{
echo "<tr>
";
//write colom
for ($j = 1; $j <= 5; $j++)
{
$cell = $sheet->Cells($i, $j); // #Select the cell (Row Column number)
$cell->activate; // #Activate the cell

if($cell->value == &#390;')
{
$td = "";
}
else
{
$td = $cell->value;
}

echo "<td>" . $td . "</td>
"; // #write the cell
}
echo "</tr>
";
}
echo "</table>
";
}

//closing excel
$excel->Quit();
?>

Mysql To Excel And Then Email The Excel Doc
I have a good working code for making a excel doc. on the fly. He send the file to the screen and you can save it directly. But I dont want it to send it to the screen but that he save it on the server and EMAILS it to someone. I'm searching and trying to get it work for 3 days, but no luck. I hope you guys can help me out.

This is the code I use the make an excel doc.


$select = "SELECT * FROM dagrapport WHERE dagrapportid='$dagrapportid'";
$result = mysql_query($select);
$datum = mysql_result($result,0,'datum');
$medewerkernummer = mysql_result($result,0,'medewerkernummer');
$export = mysql_query($select);
$fields = mysql_num_fields($export);
$kop = "";
$data = "";
for ($i = 0; $i < $fields; $i++) {
$kop .= mysql_field_name($export, $i) . " ";
}

while($row = mysql_fetch_row($export)) {
$line = ''
foreach($row as $value) {
if ((!isset($value)) OR ($value == "")) {
$value = " ";
} else {
$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . " ";
}
$line .= $value;
}
$data .= trim($line)."
";
}
$data = str_replace("
","",$data);

if ($data == "") {
$data = "
(0) Records Found!
";
}

header("Content-type: application/x-msexcel");
header("Content-Disposition: attachment; filename=dagrapport-$datum-$medewerkernummer.xls");
header("Pragma: no-cache");
header("Expires: 0");
print "$kop
$data";

Importing A Flat Pipe Delimited File Into A MySQL Data Table
I have done this in perl but eeew I don't want to use perl anymore. I
want to be able to take a flat file that looks like this:

mbriones@...|Marian|Briones
bobsmith@...|Bob|Smith
janedoe@...|Jane|Doe
(etc)

The table has more than 3 fields, so I'd want to process the flat file
and then do an INSERT into mailinglist SET field=$value for each line.

Does someone have a nice way for me to do this? The flat file will be
uploaded to the server via a form (copy) and then be processed.

Comma Separated List In MySQL Field
say I have a list of categories in a field, and a page that is supposed to pull from the db based on a category. Is there any way I can do a query where it searches the contents of that field for the category in question?

like SELECT FROM table WHERE category = $category  but have it search the category field (the comma separated list for each entry) for the $category var

From MySQL To Excel (through PHP)
it's possible to manage an exixtent excel file with PHP? :
i already have an excel file formatted in many fileds,
and i have to modify only some of these fields (i need to add data).

unrotunately with tutorials i found trough google i can substitute tables
in my excel file, and i cannot modify the fields, it overwrites and stop.

Excel To MySQL
I currentley use Navicat for most of my Excel to MySQL conversions. But I would like to get this web based.

Ideally the user would submit a standard .xls via a form upload.

Now here is the complex part. The file has 6 spreadsheets in it. Each spreadsheet has different columns and some of those columns need to go into different tables. So it's NOT just xls to one mysql table. It's actuallt one xls file with numerous spreadsheets going into different MySQL tables based on the column names.

Excel > XML > MySQL
I am wondering if there is a way I can use an upload form to upload an Excel XML export or just an .xls file to a MySQL database. I am also wondering if there is a tutorial out there that can help. So far I have only been able to find sites that offer tools to do it, but I want to use an upload form instead.

Php , Mysql And Excel
IŽd want to pass the result of a mysql to an xls file (excel) , obviously all into my php page.

Is it possible? You know, can I pass the results as a whole or do i have to extract each parameter and put it into an xls file ( i have no idea how to do it).  Maybe some of you have done it or can give me a clue.

Exporting Mysql To Csv Or Excel Via PHP
Hi, I need to know how to write a php code how to export the mysql database into CSV or Excel or ISO 20001 format. or if you know any tutorial site for it.

Need To Convert Mysql To Excel?
I need to display data from MySQL to Excel format. I looked at several excel classes, but they are missing three things that I need.

1. To be able to output a cell larger than 255 characters.
2. Be able to keep line breaks in cells.
3. be able to format the cell widths

I am currently using a tab delimited set up with excel http headers, but I can not format the cell widths.

Excel Data To Mysql
Is this possible to transfer excel data to mysql database?

Data From MySQL Into CSV For Excel?
I've a survey form that I need to get data from and put into a mySQL
database.
Easy, can do it eyes closed.

But, then I need to be able to take that same information and convert
it (either directly or pulling it back out from the database) into a
CSV (or any file for that matter) that can be easily imported, added
into an existing Excel database.

I've no idea how to do that. (I can query the database, that I can do,
and create recordsets, AND create text files, but I've never created a
CSV file before.)

Is there a source, a good Web site for example, that explains that
kind of process pretty well?

MySQL Dump To Excel
I get an error on the actual dump. It does dump the file, so I know I am connecting and downloading. But, it puts all records in one line of text in the browser, and does not give me the prompt to download. Code:

Download MySQL Data To Excel
I have no issue in getting my data to download into MySQL, but can you

A) Style the info? So like make a certain font and size?

B) It isn't displaying my table column names as the heading any clues?

This is what I have PHP Code:

Importing Excel Into A MySQL Database
i have an excel file I want to read into a database.  I found a tutorial which says to save the file into a xml file, then it basically gets all the data out, and puts it into an array Code:

Export MySQL To Certain Excel Cells
I have  .xls files that I want to be able to export MySQL data into.  Is there a straightforward way to do this...I'll really only be inputing 2-3 values.

So pretend I have:

$test1
$test2
$test3

And I want to export them into test.xls in cells  A1, A2, A3.  Can someone provide the method for doing this?

Excel File Imported Into MySQL
I have a Excel sheet, you can save this sheet as a wide range of extensions, the main one being .xls, but you can also do .txt tab delimited , html, .cvs, etc.... I'm very new to PHP and SQL. I'm trying to grab several columns of values, with like 200 rows. Each Column is labeled say - Model - Manufacturer - Name - Item # - Serial # etc... with each row under it displaying the info for that item.

Is there any way I can take that excel sheet and import it into the MySQL database or PHP?? I'm very new, so a very detailed explanation would be of GREAT assistance. Thank you allot in advanced, this will save me 3 hours of work for something that might be done in 10 minutes.

Putting Mysql Data Into An Excel Spreadsheet
I want to take data from a MySQL database and stick it into an Excel Spread sheet so the speadsheet is upto date and with data format intact. any easy way to do this?

I don't want to just drop data into the spread sheet. Diffent bits have to go in different places. Basicly the fields names arn't going to be the colum names ect.

Import Excel File Into MySQL Database
I am relatively new in this field, and one of my first challenge is the following :

Importing an Excel file, containings URL, into a MySQL database.

It must be the simplest process possible for the end user, avoiding as far as
possible all steps of converting and/or transforming files.
Of course, we want to preserve the identity of the URL.

Import Excel File To Mysql Database
i want to import excel file into mysql database .

Exporting Data From Mysql Using Php In Excel Form..?
I have a table in mysql wich contain a sim_number field which is 19 digit unsigned number. i have designed a script using php headear command for exporting data as excel. It is working but with the follwoing problem.
Since sim_number is 19 digit number when it get exported as .xls file. now when that .xls file is opened, excel automatically detect this sim_number as number and , since excel can store only 15 digit in number format it converts its last 4 digits to zeros.

Is there any way to get this sim_number exported as text so that excel store complete 19 digit number in text format. I cannot attach some charctor to this sim_number because of restricion on file format.

Importing Excel File Into Mysql Database
I need help regarding importing excel file into mysql database.I am using PHP 5.0.2, mysql 4.2.13. I need code for importing excel file into mysql database and what will be the steps for it.

Transferring Excel Data To Mysql Table
Is it possible to transfer the whole data from excel sheet to the mysql database?

How Data Can Be Imported From Excel Sheet Into MySQL Database.
How data can be imported from Excel sheet into MySQL database. And also
data can be exported from MySQL to Excel sheet.

How Data Can Be Imported From Excel Sheet Into MySQL Database
How data can be imported from Excel sheet into MySQL database. And also data can be exported from MySQL to Excel sheet.

How To Convert Carriage Return In Mysql To Excel Format?
I have a varchar field in MySQL table that has carriage returns. I am trying to display this field in an Excel document. When I display this using (php_writeexcel class ) Excel I get small squares due to Excel converting the carriage returns.

Is there a way to convert these carriage returns to display properly. I have already tried str_replace("","",$value) and does not work. Any regular expressions?

Create A Button To Export A Mysql Table To An Excel File.
Does anyone have the code that creates a link, and on click, takes a specified table in my database and exports and downloads an excel file?

Reading An MYSQL Row
I have a small problem. I want to read 3 colums that have information in MySQL. Here is an example: I have one column for users (userid), passwords (passid), for e-mail (emailid), and url(siteid). How can I read passid, emailid, and siteid and put them into a text box for a form. like:

<!-- beginning -->
$connect = @MYSQL_PCONNECT($host,$user,$pass);
$query = MYSQL_DB_QUERY($db,"SELECT userid,passid,emailid,siteid FROM users WHERE userid = $user_logged")
<!-- end -->

what do i do to enter passid, emailid, and siteid that belong to $user_logged into their own text box , like in a form?

Php To Excel : Can You Format The Excel Sheet?
I can create a file to download to excel, but I would like to know if you can bold the excel sheet or make headers and change the width of the cells. If not feel free to say impossible in php.

Help Req. Reading Data From MySQL Db With PHP
I have PHP code (below) which reads data from a MySQL format database. The
problem I am having is trying to find out when the last ID entry was made.
When the script is executed, the $gbID is supposed to be read and display
the last entered ID number ($How_many_entries) - the ID number is entered /
updated automatically in another PHP script which deals with data entry to
the database.

But instead of displaying the result of the query, it displays the ID
number ($How_many_entries) as "Resource id #4", and looking around the
search engines, no page makes particular sense as to what I've done wrong.

Does anyone know how to get the $gbID number from the database and into
$How_many_entries so I can perform some math work on it?

<?
$DatabaseName = "Guestbook";
$table_to_look_for = "entries";

$connection = @mysql_connect("localhost") or die("<B>Could not connect to
MySQL: </B>".mysql_error());

mysql_select_db($DatabaseName);

// get all tables in the database
$result = @mysql_list_tables ("DatabaseName");

// Display database entries in reverse order (remove 'DESC' to have forward
display of results)
$sql = "SELECT gbID, gbDate, gbIP, gbURL, gbName, gbComment FROM
$table_to_look_for ORDER BY gbid DESC";

$result = @mysql_query($sql, $connection) or die("<B>Problem reading from
database: </B>".mysql_error());

while ($row = mysql_fetch_array($result))
{
$gbID = $row['gbID'];
$gbDate = gmstrftime('%A %d %B %Y at $T',strtotime($row['gbDate']));
$gbURL = $row['gbURL'];
$gbName = $row['gbName'];
$gbComment = nl2br($row['gbComment']);

$display_entry .= "$gbID:<BR><B>Posted on: </B>$gbDate &nbsp;<B>IP:
</B>Logged<BR><B>Posted by: </B>$gbName<BR><B>Personal website:
</B>$gbURL<BR><B>Comment: </B>$gbComment<BR><BR>";
}

$sql = "SELECT last_insert_id($gbID) FROM $table_to_look_for";
$How_many_entries = @mysql_query($sql, $connection);

// $How_many_entries = $How_many_entries / 5;
echo "Entries: $How_many_entries<BR>";

etc....

About Mysql Reading And Newsgroups
I took quite elaborate SQL and SQL-admin courses at Oracle, but that was
years ago. Have never since used SQL but for some extremely simple
straightforward queries on single table db's. So while conjoins, inner and
outer joins et cetera ring some bells, I wouldn't know how to tell one from
the other anymore, let alone put them to good use.

So I decided to check for some good reading material that starts from
scratch but quickly picks up. I haven't really found a lot yet, my library
has zip and I don't want to buy before I try or be sure its worth the cost.
I am a rather quick learner I think, with a preference for visual support
and try it yourself quiz-type quick snippets. If there is a choice in
underlying OS, I prefer Linux to Win32.

I also tried to find some good newsgroups, and while PHP has several, I
can't find a good english (or dutch) ng on mysql (at least not on my
isp-server). Do you peeps have some tips on good reading/study material and
newsgroups to look for ?

Reading Multiple Lines From Mysql
I made a phpscript to enter data into my database, all works fine. I've got a <textarea> where i enter for example the following text (without the qoutes):

"Hi, my name is Joey,
i luv scripting and online gaming.
I live in belgium, lovely country
but bad weather"

the script enters that text into the table. Another script of mine queries the database for the text, but it outputs:

"Hi, my name is Joey, i luv scripting and online gaming. I live in Belgium, lovely country but bad weather"

It's just one strait line and not the block i entered. Anyone know how i fix that? It also happens when i input 2 word or more in a <input type=text>. The data is in the table but when i reinput it into an <input type=text> (for editing) it only inputs one word.

Switch Statement + Reading From MySQL DB
I have created a templated site, with the use of switch statements [shown below] Anyway, this works fine, accept the person I am doing this for knows little html so what I want to do is be able for him to add new sections easily without doing any HTML, thus the MySQL DB.

But I am stumped what is the best way to do this?? I would be very grateful if someone can help.. PHP Code:

Reading MySQL Data In A Form Field
i am in the process of building an admin page for a site. Most of my site data is being held in MySQL and being pulled using PHP. The problem I have is while trying to build an Admin form to change data in MySQL, I want to have the data that is currently in the table be automatically put into the form field, so they can see what they are changing before they change it, or so if they do nothing it keeps the same data in it. My code is as follows:

Problem Reading Data Out Of MySQL Db, PHP Variables
Below is part of a code I have for a database. While the database table is
created correctly (if it doesn't exist), and data is input correctly into
the database when executed, I have a problem when reading out the data into
the PHP variables / array.

It should be displaying the information out in the following way, using
the PHP array:

n_date, n_headline, n_summarytext, n_fulltext

But what actually gets displayed is the data for:

n_date, n_headline, n_summarytext

So the "n_fulltext" is not displayed, but the echo'ed text preceeding it
"Full text:" is displayed, but it is not reading the information out of the
variable. I have checked that there is information input in this field in
the db, and it is there.....

Reading And Displaying A Date From A MySql Database
I've just started using php, and although I am very impressed by it,
there are some things with which I am confounded!

What I'm trying to do is read in a Date from a mySql database and then
display it on screen (the Date is in the usual yyyy-mm-dd format).

If I use SQL on phpadmin
SELECT Date
FROM details
WHERE details.Name = "Paul Lee"
LIMIT 0 , 30

The result comes up 2005-01-01, so this seems to work.
But if I use the following:

$db = mysqli_connect("localhost","root","");
@mysqli_select_db($db, "personnel") or die ( "Unable to select
database" );
$query = 'SELECT Date FROM details WHERE details.Name = "Paul Lee"
LIMIT 0, 30'

$result=mysqli_query($db, $query);

echo "<br>";

echo $result;

mysqli_close($db);

I get "Object id #2" displayed on screen.
I have tried to use the explode function to separate the months, year
and day using the "-" as a delimeter, but this doesn't work, and I
can't seem to get the other php date/time functions to work either.

Reading Rfrom Mysql & Writing To Txt File
I am trying to write a simple script (see below) that connects to a database, pulls out information on each row, and puts that information on each row into a variable before printing it into a text file. This is the script: Code:

Reading From Text File And Storing In MySQL
I have a text file consist of 10 digit phone numbers one number per line like this:

5553332244
5553332244
5553332244
5553332244

etc…

How do I read a text file line by line and populate the data into an array to store it into a MySQL database? My database is below:

MYSQL Query Script To Reading From A Text File
Im having a hard time converting the following tree menu script to read nodes from a text file, rather then a database.  This script works perfectly and is exactly what i am looking for, however it relies on query's from a MySQL database (I don't know how to set one up is the real problem).  I would like to keep the feature where you can pass a parameter through the script and its expands the corresponding folder. Code:

Delimiting A Non-delimited File
I have a text file, with addresses of business' that I would like to convert to a more useable format ie CSV. Currently there is no delimiting of the various address components.

"A 1 AUTO SALES 1224 S BROADWAY ST WICHITA, KS 67211-3124 316-263-8748"
"ABERLE FORD INC 1025 MAIN ST SABETHA, KS 66534-1893 913-284-3122"
"ACTION AUTO RENTAL & SALES 1101 W 4TH AVE HUTCHINSON, KS 67501 316-662-3699"

As you can see from the examples above the only consistent items are the state and the phone number, and the city is always followed by a comma. I am new to regex and the whole range of string handling functions and I am not sure where to start.

Exploding Tab Delimited Line
I'm trying to create an array from a tab delimited line of text. I've tried explode('/t',$line); but doesn't seem to work. What am I doing wrong?


Copyright © 2005-08 www.BigResource.com, All rights reserved