Foros del Web » Programación para mayores de 30 ;) » Bases de Datos General » Mysql »

importar directamente a BD mysql

Estas en el tema de importar directamente a BD mysql en el foro de Mysql en Foros del Web. Hola he preguntado este tema en el foro de asp pero no he logrado aun lo ke necesito necesito importar un archivo de cualquier extencion ...
  #1 (permalink)  
Antiguo 05/06/2009, 07:24
Avatar de lexus  
Fecha de Ingreso: enero-2002
Ubicación: Cali - Colombia
Mensajes: 2.234
Antigüedad: 22 años, 3 meses
Puntos: 4
Desacuerdo importar directamente a BD mysql

Hola

he preguntado este tema en el foro de asp pero no he logrado aun lo ke necesito

necesito importar un archivo de cualquier extencion ya sea, excel, html, o nose yo se la puedo poner.. pero tiene un formato de html con tablas..

bueno en fin.. la idea que tengo o lo qeu necesito es importar el contenido de esa tabla de html a una base de datos mysql..
hay alguna instruccion sql para importar este tipo de archivos?
o conocen alguna forma para que yo importe esstos datos directamente a mi base de datos mysql?

el archivo es un excel generado por asp..
tiene esta forma..

Código HTML:
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content="Microsoft Excel 11">
<link rel=File-List href="excel_productos_archivos/filelist.xml">
<link rel=Edit-Time-Data href="excel_productos_archivos/editdata.mso">
<link rel=OLE-Object-Data href="excel_productos_archivos/oledata.mso">
<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:LastAuthor>oktopus</o:LastAuthor>
  <o:LastSaved>2009-05-30T17:17:31Z</o:LastSaved>
  <o:Version>11.9999</o:Version>
 </o:DocumentProperties>
</xml><![endif]-->
<style>
<!--table
 {mso-displayed-decimal-separator:"\,";
 mso-displayed-thousand-separator:"\.";}
@page
 {margin:.98in .79in .98in .79in;
 mso-header-margin:0in;
 mso-footer-margin:0in;}
tr
 {mso-height-source:auto;}
col
 {mso-width-source:auto;}
br
 {mso-data-placement:same-cell;}
.style0
 {mso-number-format:General;
 text-align:general;
 vertical-align:bottom;
 white-space:nowrap;
 mso-rotate:0;
 mso-background-source:auto;
 mso-pattern:auto;
 color:windowtext;
 font-size:10.0pt;
 font-weight:400;
 font-style:normal;
 text-decoration:none;
 font-family:Arial;
 mso-generic-font-family:auto;
 mso-font-charset:0;
 border:none;
 mso-protection:locked visible;
 mso-style-name:Normal;
 mso-style-id:0;}
td
 {mso-style-parent:style0;
 padding-top:1px;
 padding-right:1px;
 padding-left:1px;
 mso-ignore:padding;
 color:windowtext;
 font-size:10.0pt;
 font-weight:400;
 font-style:normal;
 text-decoration:none;
 font-family:Arial;
 mso-generic-font-family:auto;
 mso-font-charset:0;
 mso-number-format:General;
 text-align:general;
 vertical-align:bottom;
 border:none;
 mso-background-source:auto;
 mso-pattern:auto;
 mso-protection:locked visible;
 white-space:nowrap;
 mso-rotate:0;}
.xl24
 {mso-style-parent:style0;
 font-weight:700;
 vertical-align:top;
 border:.5pt solid black;
 white-space:normal;}
.xl25
 {mso-style-parent:style0;
 font-weight:700;
 vertical-align:top;
 border-top:.5pt solid black;
 border-right:.5pt solid black;
 border-bottom:.5pt solid black;
 border-left:none;
 white-space:normal;}
.xl26
 {mso-style-parent:style0;
 font-weight:700;
 text-align:center;
 vertical-align:top;
 border-top:.5pt solid black;
 border-right:.5pt solid black;
 border-bottom:.5pt solid black;
 border-left:none;
 white-space:normal;}
.xl27
 {mso-style-parent:style0;
 vertical-align:top;
 border-top:none;
 border-right:.5pt solid black;
 border-bottom:.5pt solid black;
 border-left:.5pt solid black;
 white-space:normal;}
.xl28
 {mso-style-parent:style0;
 text-align:center;
 vertical-align:top;
 border-top:none;
 border-right:.5pt solid black;
 border-bottom:.5pt solid black;
 border-left:none;
 white-space:normal;}
.xl29
 {mso-style-parent:style0;
 vertical-align:top;
 border-top:none;
 border-right:.5pt solid black;
 border-bottom:.5pt solid black;
 border-left:none;
 white-space:normal;}
.xl30
 {mso-style-parent:style0;
 text-align:right;
 vertical-align:top;
 border-top:none;
 border-right:.5pt solid black;
 border-bottom:.5pt solid black;
 border-left:none;
 white-space:normal;}
-->
</style>
<!--[if gte mso 9]><xml>
 <x:ExcelWorkbook>
  <x:ExcelWorksheets>
   <x:ExcelWorksheet>
    <x:Name>excel_SAR</x:Name>
    <x:WorksheetOptions>
     <x:DefaultColWidth>10</x:DefaultColWidth>
     <x:Selected/>
     <x:DoNotDisplayGridlines/>
     <x:LeftColumnVisible>3</x:LeftColumnVisible>
     <x:Panes>
      <x:Pane>
       <x:Number>3</x:Number>
       <x:ActiveRow>8</x:ActiveRow>
       <x:ActiveCol>4</x:ActiveCol>
      </x:Pane>
     </x:Panes>
     <x:ProtectContents>False</x:ProtectContents>
     <x:ProtectObjects>False</x:ProtectObjects>
     <x:ProtectScenarios>False</x:ProtectScenarios>
    </x:WorksheetOptions>
   </x:ExcelWorksheet>
  </x:ExcelWorksheets>
  <x:WindowHeight>9345</x:WindowHeight>
  <x:WindowWidth>18780</x:WindowWidth>
  <x:WindowTopX>240</x:WindowTopX>
  <x:WindowTopY>105</x:WindowTopY>
  <x:ProtectStructure>False</x:ProtectStructure>
  <x:ProtectWindows>False</x:ProtectWindows>
 </x:ExcelWorkbook>
</xml><![endif]-->
</head>
<body link=blue vlink=purple>
<table x:str border=0 cellpadding=0 cellspacing=0 width=1642 style='border-collapse:
 collapse;table-layout:fixed;width:1232pt' name=inicio>
 <col width=159 style='mso-width-source:userset;mso-width-alt:5814;width:119pt'>
 <col width=183 style='mso-width-source:userset;mso-width-alt:6692;width:137pt'>
 <col width=108 style='mso-width-source:userset;mso-width-alt:3949;width:81pt'>
 <col width=152 style='mso-width-source:userset;mso-width-alt:5558;width:114pt'>
 <col width=126 style='mso-width-source:userset;mso-width-alt:4608;width:95pt'>
 <col width=594 style='mso-width-source:userset;mso-width-alt:21723;width:446pt'>
 <col width=152 style='mso-width-source:userset;mso-width-alt:5558;width:114pt'>
 <col width=168 style='mso-width-source:userset;mso-width-alt:6144;width:126pt'>
 <tr height=20 style='mso-height-source:userset;height:15.0pt' name=encabezado>
  <td height=20 class=xl24 width=159 style='height:15.0pt;width:119pt'
  name="codigo_empresa">CODIGO_SAR</td>
  <td class=xl25 width=183 style='width:137pt' name="codigo_proveedor">CODIGO_PROVEEDOR</td>
  <td class=xl26 width=108 style='width:81pt' name="id_unidad">ID_UNIDAD</td>
  <td class=xl26 width=152 style='width:114pt' name=unidad>UNIDAD</td>
  <td class=xl26 width=126 style='width:95pt' name="id_producto">ID_PRODUCTO</td>
  <td class=xl25 width=594 style='width:446pt' name="nombre_producto">NOMBRE_PRODUCTO</td>
  <td class=xl25 width=152 style='width:114pt' name="precio_pesos">PRECIO_PESOS</td>
  <td class=xl25 width=168 style='width:126pt' name="precio_dolares">PRECIO_DOLARES</td>
 </tr>
 <tr height=20 style='mso-height-source:userset;height:15.0pt' name=1>
  <td height=20 class=xl27 align=right width=159 style='height:15.0pt;
  width:119pt' x:num name="codigo_empresa">1010001</td>
  <td class=xl28 width=183 style='width:137pt' name="codigo_proveedor">-</td>
  <td class=xl28 width=108 style='width:81pt' x:num name="id_unidad">2</td>
  <td class=xl28 width=152 style='width:114pt' name=unidad>UNIDAD</td>
  <td class=xl28 width=126 style='width:95pt' x:num name="id_producto">1</td>
  <td class=xl29 width=594 style='width:446pt' name="nombre_producto">WT 1
  73PULG X 15 M ANSI 150</td>
  <td class=xl30 width=152 style='width:114pt' x:num name="precio_pesos">500</td>
  <td class=xl30 width=168 style='width:126pt' x:num name="precio_dolares">1500</td>
 </tr>
 <tr height=20 style='mso-height-source:userset;height:15.0pt' name=2>
  <td height=20 class=xl27 align=right width=159 style='height:15.0pt;
  width:119pt' x:num name="codigo_empresa">1010002</td>
  <td class=xl28 width=183 style='width:137pt' name="codigo_proveedor">-</td>
  <td class=xl28 width=108 style='width:81pt' x:num name="id_unidad">2</td>
  <td class=xl28 width=152 style='width:114pt' name=unidad>UNIDAD</td>
  <td class=xl28 width=126 style='width:95pt' x:num name="id_producto">2</td>
  <td class=xl29 width=594 style='width:446pt' name="nombre_producto">WT 2 ANSI
  150 48PULG X 15'</td>
  <td class=xl30 width=152 style='width:114pt' x:num name="precio_pesos">0</td>
  <td class=xl30 width=168 style='width:126pt' x:num name="precio_dolares">0</td>
 </tr>
 <![if supportMisalignedColumns]>
 <tr height=0 style='display:none'>
  <td width=159 style='width:119pt'></td>
  <td width=183 style='width:137pt'></td>
  <td width=108 style='width:81pt'></td>
  <td width=152 style='width:114pt'></td>
  <td width=126 style='width:95pt'></td>
  <td width=594 style='width:446pt'></td>
  <td width=152 style='width:114pt'></td>
  <td width=168 style='width:126pt'></td>
 </tr> <![endif]></table></body></html>
 
 
 
 
__________________
Control de Visitantes, Control de Accesos, Minutas digitales, Manejo de Correspondencia
http://www.controldevisitantes.com
  #2 (permalink)  
Antiguo 07/06/2009, 10:25
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Sabadell
Mensajes: 4.897
Antigüedad: 16 años, 1 mes
Puntos: 574
Respuesta: importar directamente a BD mysql

mysql importa automaticamente archivos .csv (coma separated values) este formato es compatible con excel... no se si puedes generarlo directemente con asp... si no como su nombre indica solo debes generar un fichero de texto con los valores separados por comas...

algo así
"CODIGO_SAR",
"CODIGO_PROVEEDOR","ID_UNIDAD","UNIDAD","ID_PRODUC TO","NOMBRE_PRODUCTO","PRECIO_PESOS","PRECIO_DOLAR ES"
"1010001","","2","UNIDAD","1","WT 1 73PULG X 15 M ANSI 150","500","1500"

No se si tines que poner la cabecera, nombres de columnas mirate este articulo A Look at the MySQL CSV Storage Engine y este Como generar utilizando ASP un archivo CSV, compatible con Excel y otras hojas de cálculo, a partir de una tabla de la base de datos

Giyf

Open is better

Quim

Última edición por quimfv; 07/06/2009 a las 10:35
  #3 (permalink)  
Antiguo 07/06/2009, 12:12
Avatar de lexus  
Fecha de Ingreso: enero-2002
Ubicación: Cali - Colombia
Mensajes: 2.234
Antigüedad: 22 años, 3 meses
Puntos: 4
Respuesta: importar directamente a BD mysql

gracias por la respuesta..

es ke mi problema
es que tengo un asp donde se genera un archivo de excel con el formato ke mostre arriba..
luego una empresa lo descarga a su computadora y lo modifica los valores y por medio de un asp nuevamente lo vuelve a subir para imprtarlo a una base de datos mysql..

por tal motivo pregunto si se puede importar directamente un excel con esa forma desde mysql . ya que me han dicho que un excel generado desde asp es un html con extension .xls.
__________________
Control de Visitantes, Control de Accesos, Minutas digitales, Manejo de Correspondencia
http://www.controldevisitantes.com
  #4 (permalink)  
Antiguo 07/06/2009, 13:06
Avatar de gnzsoloyo
Moderador criollo
 
Fecha de Ingreso: noviembre-2007
Ubicación: Actualmente en Buenos Aires (el enemigo ancestral)
Mensajes: 23.324
Antigüedad: 16 años, 4 meses
Puntos: 2658
Respuesta: importar directamente a BD mysql

En cualquier caso, si es un .HTML, no es un .CSV, por lo que no se puede importar directamente por ningún medio que MySQL cuente.
MySQL espera recibir (en el caso de LOAD DATA INFILE), un archivo plano, donde los campos estén separaos por coas. Cualquier otra cosa que contenga el archivo generará errores de lectura, y un HTML tiene montones de cosas que no son parte de la tabla de datos...
Esto lo tienes que administrar con la aplicación.
__________________
¿A quién le enseñan sus aciertos?, si yo aprendo de mis errores constantemente...
"El problema es la interfase silla-teclado." (Gillermo Luque)
  #5 (permalink)  
Antiguo 08/06/2009, 01:28
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Sabadell
Mensajes: 4.897
Antigüedad: 16 años, 1 mes
Puntos: 574
Respuesta: importar directamente a BD mysql

Ya te he dicho que .csv es compatible con excel... es decir tu genera el .csv y los de la empresa podran abrirlo con excel modificarlo y luego lo deben guardar en csv y subirlo, así si podrás importarlo.

Quim
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:01.