PageSourceSearch

https://conversiontab.com/build/assets/csv-tool-page-Cn7cbwT2.js

js conversiontab.com collected 2026-09-24 10:06:53 UTC 17,516 bytes, 35 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ctFullscreenAd-CL-AA_Ul.js","assets/app-gOHIPY12.js"])))=>i.map(i=>d[i]);
2import{_ as Ie,T as Be}from"./app-gOHIPY12.js";import{s as xe}from"./a11yTextFileTabs-aQqfQEU0.js";import{P as Fe}from"./papaparse.min-DtqB8VRF.js";import{C as Te,d as we,b as qe,c as Ne,s as $e,i as Ae,M as pe,r as Oe}from"./csvSqlCore-M_4k9GW7.js";import{b as Re,c as ie,a as De,g as _e,d as Me,e as Pe}from"./csvExportFormats-DPHu0Bph.js";import{c as Ve}from"./ctPendingDownload-B21SXRKd.js";import{f as He}from"./ctBlobExportFinish-D9AIdnhb.js";import{c as re,V as Ze,a as je,b as ze,d as We}from"./formatHubIcsVcf-BssvIWBl.js";import{v as Xe}from"./vcfDemoTabular-CQFX71rE.js";import{bindHashStyleCopy as Ke}from"./hashStyleCopy-B7l2OPhl.js";import{w as Ue,c as F}from"./fileDropzone-CA_uaFcV.js";import{s as N}from"./buttonBusy-DoyqFlQ8.js";import"./_commonjsHelpers-BosuxZz1.js";import"./FileSaver.min-BR20wtAe.js";import"./ctFullscreenAd-CL-AA_Ul.js";import"./xlsx-D_0l8YDs.js";import"./transientNotice-Ds_di7lD.js";const Ye="Invalid",Ge="File is empty",Je=`The file size exceeds the limit of ${pe}MB`,Qe=["HOME","WORK","CELL","VOICE","FAX","PAGER","CAR","VIDEO","BILL","ADDITIONAL","OTHER","PERSONAL"],et=[{label:"None",value:""},{label:"Comma ,",value:","},{label:"Tab",value:"	"},{label:"Semi Colon ;",value:";"},{label:"Space",value:" "},{label:"Colon :",value:":"},{label:"Bar |",value:"|"}],tt=Xe(),nt=`summary,description,location,datestart,dateend,organizer,uid
3Project XYZ Weekly Meeting,Meeting to discuss project XYZ.,Conference Room 1A,1997-07-14T17:00:00Z,1997-07-15T04:00:00Z,[email protected],[email protected]`;function de(){return{FirstRowIsColumnNames:!0,limitOfLines:"",skipOfLines:"",fieldSeprator:"",customFieldSeparator:"",primaryKey:"Primary_key",keepOriginalFieldNames:!0,encloseFieldNames:!0,encloseFieldNamesWith:"backtick",columns:[],schemaTableOrViewName:"table_name"}}function h(u,c=!0){const m=document.getElementById("ctCsvSqlToast"),p=document.getElementById("ctCsvSqlToastBody");if(!m||!p){window.alert(u);return}p.textContent=u,m.classList.remove("text-bg-success","text-bg-danger"),m.classList.add(c?"text-bg-danger":"text-bg-success"),Be.getOrCreateInstance(m,{delay:4e3}).show()}function ue(u){if(!u)return"";const c=u.value.trim();if(c==="")return"";const m=parseInt(c,10);return Number.isNaN(m)?"":m}function st(u){if(!u.trim())return;const c=u.split(`
4`)[0],m=[",",";",":","	"," ","|"];for(const S of m)if(c.includes(S))return S;const p=c.match(/[^a-zA-Z0-9]/);return p?{custom:p[0]}:null}function me(u){return{sql:"sql",json:"json",xml:"xml",html:"html",yaml:"yaml",pdf:"html",vcf:"vcf",ics:"ics"}[u]||"txt"}function Et(){var K,U,Y,G,J,Q,ee,te,ne,se,ae,le,oe;const u=document.getElementById("ct-csv-tool-root");if(!u)return;const c=(u.dataset.ctCsvPage||"sql").toLowerCase(),m=c==="sql",p=c==="vcf"||c==="ics",S=c==="xlsx"||c==="pdf",_=c==="xlsx"?"converted_data":"converted",fe=c==="xlsx"?".xlsx":".pdf";let a=de(),i="",T="",C=[],M,d=re(p?c:"vcf"),y=[],w=null,I="";const q=Ve(),e={ta:document.getElementById("ctCsvSqlText"),fileInput:document.getElementById("ctCsvSqlFile"),fileZone:document.getElementById("ctCsvSqlFileZone"),btnClear:document.getElementById("ctCsvSqlClear"),btnSample:document.getElementById("ctCsvSqlSample"),tabText:document.getElementById("ctCsvSqlTabText"),tabFile:document.getElementById("ctCsvSqlTabFile"),panelText:document.getElementById("ctCsvSqlPanelText"),panelFile:document.getElementById("ctCsvSqlPanelFile"),chkFirstRow:document.getElementById("ctCsvSqlFirstRow"),limitLines:document.getElementById("ctCsvSqlLimitLines"),skipLines:document.getElementById("ctCsvSqlSkipLines"),sepRadios:u.querySelectorAll('input[name="ct_field_sep"]'),customSep:document.getElementById("ctCsvSqlCustomSep"),chkEnclose:document.getElementById("ctCsvSqlEnclose"),encloseRadios:u.querySelectorAll('input[name="ct_enclose_with"]'),schemaName:document.getElementById("ctCsvSqlSchema"),colBody:document.getElementById("ctCsvSqlColBody"),resultTa:document.getElementById("ctCsvSqlResult"),fileName:document.getElementById("ctCsvSqlFileName"),btnCopy:document.getElementById("ctCsvSqlCopy"),btnDownload:document.getElementById("ctCsvSqlDownload"),sqlBtns:u.querySelectorAll(".ct-csv-sql__sql-bar [data-sql-mode]"),btnConvert:document.getElementById("ctCsvBtnConvert"),fileDropCaption:document.getElementById("ctCsvSqlFileDropCaption"),mapBody:document.getElementById("ctCsvMapBo
4dy"),mapAcc:document.getElementById("ctCsvVcardAccOutput")},ve=Ke(e.btnCopy,()=>T,t=>h(t,!0));function $(t){t.forEach(n=>{n.classList.remove("btn-success"),n.classList.add("btn-outline-success")})}function ye(t,n){t.forEach(s=>{const l=s.dataset.sqlMode===n;s.classList.toggle("btn-success",l),s.classList.toggle("btn-outline-success",!l)})}function b(){const t=i.trim().length>0;e.btnClear&&(e.btnClear.disabled=!t),e.btnSample&&(e.btnSample.disabled=t),p&&e.mapAcc&&e.mapAcc.classList.toggle("d-none",!t),m?e.sqlBtns.forEach(n=>{n.disabled=!t}):e.btnConvert&&(e.btnConvert.disabled=!t)}function A(){e.chkFirstRow.checked=a.FirstRowIsColumnNames,e.limitLines.value=a.limitOfLines===""?"":String(a.limitOfLines),e.skipLines.value=a.skipOfLines===""?"":String(a.skipOfLines),e.customSep.value=a.customFieldSeparator||"",e.chkEnclose.checked=a.encloseFieldNames,e.schemaName.value=a.schemaTableOrViewName,e.sepRadios.forEach(t=>{t.checked=t.value===a.fieldSeprator}),e.encloseRadios.forEach(t=>{t.checked=t.value===a.encloseFieldNamesWith})}function E(){a.FirstRowIsColumnNames=e.chkFirstRow.checked,a.limitOfLines=ue(e.limitLines),a.skipOfLines=ue(e.skipLines),a.customFieldSeparator=e.customSep.value.slice(0,1),a.keepOriginalFieldNames=!0,a.encloseFieldNames=e.chkEnclose.checked,a.schemaTableOrViewName=e.schemaName.value||"table_name";const t=[...e.sepRadios].find(s=>s.checked);a.fieldSeprator=t?t.value:"";const n=[...e.encloseRadios].find(s=>s.checked);a.encloseFieldNamesWith=n?n.value:"backtick"}function B(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function O(t){return B(t).replace(/'/g,"&#39;")}function P(){return y}function V(){const t=a.fieldSeprator||a.customFieldSeparator||",",n=Fe.parse(i,{delimiter:t,preview:1,skipEmptyLines:!0}),s=Array.isArray(n.data)&&Array.isArray(n.data[0])?n.data[0]:[];return s.length?a.FirstRowIsColumnNames!==!1?s.map((l,o)=>l==null||l===""?`Column${o+1}`:String(l)):s.map((l,o)=>`Column${o+1}`):[]}function H(){var n;const t=(((n=e.ta)==null?void 0:n.value)||"").trim()?e.ta.value:i;if(t.trim()&&(i=t,!y.length))try{if(y=V(),y.length)return;const s=t.split(/\r?\n/).find(r=>r.trim().length>0)||"";if(!s)return;const l=a.fieldSeprator||a.customFieldSeparator||",",o=s.split(l);o.length&&(y=a.FirstRowIsColumnNames!==!1?o.map((r,k)=>r==null||String(r).trim()===""?`Column${k+1}`:String(r).trim()):o.map((r,k)=>`Column${k+1}`))}catch{y=[]}}function R(){if(!p)return;const t=P();d=We(t,d)}function f(){if(!p||!e.mapBody)return;H();const t=P();if(e.mapBody.innerHTML="",!t.length){e.mapBody.innerHTML=`<tr><td colspan="${c==="vcf"?5:4}" class="text-body-secondary small">Paste CSV above to load mapping options.</td></tr>`;return}d.forEach((o,r)=>{const k=document.createElement("tr"),ce=Ze.has(String(o.key||"").toUpperCase()),Ee=t.map(v=>`<option value="${O(v)}" ${o.source===v?"selected":""}>${B(v)}</option>`).join(""),Se=Qe.map(v=>`<option value="${v}" ${String(o.type||"PERSONAL").toUpperCase()===v?"selected":""}>${v}</option>`).join(""),Le=et.map(v=>`<option value="${O(v.value)}" ${String(o.separator??",")===v.value?"selected":""}>${B(v.label)}</option>`).join(""),ke=c==="vcf"&&ce?`<button type="button" class="btn btn-outline-secondary btn-sm py-0 px-2 me-1 ct-map-add" data-i="${r}">+</button>
5                   ${o.isOriginal===!1?`<button type="button" class="btn btn-outline-danger btn-sm py-0 px-2 me-1 ct-map-del" data-i="${r}">-</button>`:""}`:"";k.innerHTML=`
6                <td>${r+1}</td>
7                <td>${ke}${B(String(o.key||""))}</td>
8                <td>
9                    <select class="form-select form-select-sm ct-map-source" data-i="${r}">
10                        <option value="">-- none --</option>
11                        ${Ee}
12                    </select>
13                </td>
14                <td class="text-center"><input type="checkbox" class="form-check-input ct-map-include" data-i="${r}" ${o.isInclude===!0?"checked":""}></td>
15                ${c==="vcf"?`<td>
16                            ${ce?`<div class="d-flex align-items-center gap-1">
17                                        <label class="small mb-0">Type</label>
18                                        <select class="form-select form-select-sm ct-map-type" data-i="${r}" style="max-width: 140px">
19                                            ${Se}
20                                        </select>
21                                        <label class="small mb-0">Sep</label>
22                                        <select class="form-select form-select-sm ct-map-sep" data-i="${r}" style="max-width: 150px">
23                                            ${Le}
24                                        </select>
25                                    </div>`:'<span class="text-body-secondary small">—</span>'}
26                           </td>`:""}
27            `,e.mapBody.appendChild(k)});const n=document.getElementById("ctCsvMapIncludeAll"),s=document.getElementById("ctCsvMapIncludeNone"),l=t.length>0;n&&(n.disabled=!l),s&&(s.disabled=!l)}function x(){if(!e.colBody)return;e.colBody.innerHTML="";const t=a.columns||[];if(!t.length){e.colBody.innerHTML='<tr><td colspan="8" class="text-body-secondary small">Paste CSV above to load columns.</td></tr>';return}t.forEach((n,s)=>{const l=document.createElement("tr");l.innerHTML=`
28        <td>${n.colNumber}</td>
29        <td><input type="text" class="form-control form-control-sm ct-col-name" data-i="${s}" value="${O(n.fieldName)}"></td>
30        <td class="small">${B(String(n.dataType))}</td>
31        <td class="small">${B(String(n.maxSize??""))}</td>
32        <td class="text-center"><input type="checkbox" class="form-check-input ct-col-key" data-i="${s}" ${n.isKey?"checked":""}></td>
33        <td class="text-center"><input type="checkbox" class="form-check-input ct-col-inc" data-i="${s}" ${n.isInclude!==!1?"checked":""}></td>
34        <td class="text-center"><input type="checkbox" class="form-check-input ct-col-trim" data-i="${s}" ${n.isTrim?"checked":""}></td>
35        <td class="text-center"><input type="checkbox" class="form-check-input ct-col-null" data-i="${s}" ${n.isNull?"checked":""}></td>`,e.colBody.appendChild(l)}),e.colBody.querySelectorAll(".ct-col-name").forEach(n=>
35{n.addEventListener("input",()=>{const s=+n.dataset.i;a.columns[s].fieldName=n.value})}),e.colBody.querySelectorAll(".ct-col-key").forEach(n=>{n.addEventListener("change",()=>{const s=+n.dataset.i;a.columns[s].isKey=n.checked})}),e.colBody.querySelectorAll(".ct-col-inc").forEach(n=>{n.addEventListener("change",()=>{const s=+n.dataset.i;a.columns[s].isInclude=n.checked})}),e.colBody.querySelectorAll(".ct-col-trim").forEach(n=>{n.addEventListener("change",()=>{const s=+n.dataset.i;a.columns[s].isTrim=n.checked})}),e.colBody.querySelectorAll(".ct-col-null").forEach(n=>{n.addEventListener("change",()=>{const s=+n.dataset.i;a.columns[s].isNull=n.checked})})}async function L(){if(E(),!i.trim()){a.columns=[],y=[],x(),f();return}try{y=V();const t=await qe(i,a);a={...a,columns:t},x(),R(),f()}catch{a.columns=[],x(),R(),f()}}function be(){w=null,I="",q.clear()}async function Z(t){const n=await He(q,{blob:t,fileNameEl:e.fileName,defaultBase:_,ext:fe,btnDownload:e.btnDownload});w=t,I=n,T="",e.resultTa&&(e.resultTa.value=""),e.btnCopy&&(e.btnCopy.disabled=!0),h(`Downloading ${n}…`,!1)}function g(t){be(),T=t,e.resultTa&&(e.resultTa.value=t),!S&&e.fileName&&(e.fileName.disabled=!t),e.btnDownload&&(e.btnDownload.disabled=!t),e.btnCopy&&(e.btnCopy.disabled=!t),t?Ie(()=>import("./ctFullscreenAd-CL-AA_Ul.js"),__vite__mapDeps([0,1])).then(n=>n.maybeShowFullscreenAd("conversion-success")):ve()}function j(){i="",e.ta&&(e.ta.value=""),a=de(),A(),g(""),e.fileName&&(e.fileName.value=S?_:""),C=[],F(e.fileInput),y=[],p&&(d=re(c)),m&&$(e.sqlBtns),x(),f(),b()}function D(){const t=st(i);t&&(t.custom?(a.fieldSeprator="",a.customFieldSeparator=t.custom):(a.fieldSeprator=t,a.customFieldSeparator=""),A())}async function z(){E();const t=a.fieldSeprator||a.customFieldSeparator||",",n=await $e(i,a);return n.ok?await Ae(i,t)?!0:(S||g(""),h(`${Ye} csv`),!1):(h(n.message),!1)}async function ge(){if(await z()){N([e.btnConvert],!0);try{if(c==="vcf"){g(je(i,a,d));return}if(c==="ics"){g(ze(i,a,d));return}switch(c){case"json":g(await Pe(i,a));break;case"xml":g(await Me(i,a));break;case"html":{const t=await ie(i,a);g(t);break}case"yaml":g(await _e(i,a));break;case"pdf":{const t=await ie(i,a),n=await De(t);await Z(n);break}case"xlsx":{const t=await Re(i,a);await Z(t);break}default:h(`No converter wired for “${c}”.`)}}catch(t){h((t==null?void 0:t.message)||String(t))}finally{N([e.btnConvert],!1),b()}}}async function he(t,n){if(await z()){N([...e.sqlBtns],!0,{loadingLabel:"Generating SQL…"});try{$(e.sqlBtns),ye(n,t);const s=await Ne(i,a,t);g(s)}catch(s){h((s==null?void 0:s.message)||String(s))}finally{N([...e.sqlBtns],!1),b()}}}(K=document.getElementById("ctCsvMapIncludeAll"))==null||K.addEventListener("click",()=>{p&&(d.forEach(t=>{t.isInclude=!0}),f())}),(U=document.getElementById("ctCsvMapIncludeNone"))==null||U.addEventListener("click",()=>{p&&(d.forEach(t=>{t.isInclude=!1}),f())}),(Y=e.ta)==null||Y.addEventListener("input",()=>{if(i=e.ta.value,i.trim()===""){j();return}D(),clearTimeout(M),M=setTimeout(()=>{L(),b()},120),b()}),(G=e.chkFirstRow)==null||G.addEventListener("change",()=>{E(),L()}),[e.limitLines,e.skipLines].forEach(t=>{t==null||t.addEventListener("change",()=>{E(),L()}),t==null||t.addEventListener("input",()=>{E(),L()})}),e.sepRadios.forEach(t=>t.addEventListener("change",()=>{E(),a.customFieldSeparator="",e.customSep.value="",L()})),(J=e.customSep)==null||J.addEventListener("input",()=>{E(),a.customFieldSeparator&&(a.fieldSeprator="",e.sepRadios.forEach(t=>{t.checked=!1})),L()}),[e.chkEnclose,e.schemaName,...e.encloseRadios].forEach(t=>{t==null||t.addEventListener("change",()=>E()),t==null||t.addEventListener("input",()=>E())}),(Q=e.mapBody)==null||Q.addEventListener("change",t=>{var l;const n=t.target,s=Number(n.dataset.i);if(!(!Number.isInteger(s)||!d[s]))if(n.classList.contains("ct-map-source")){d[s].source=n.value;const o=!!(n.value&&String(n.value).trim());d[s].isInclude=o;const r=(l=n.closest("tr"))==null?void 0:l.querySelector(".ct-map-include");r&&(r.checked=o)}else n.classList.contains("ct-map-type")?(d[s].type=String(n.value||"PERSONAL").toUpperCase().replace(/\W/g,"")||"PERSONAL",n.value=d[s].type):n.classList.contains("ct-map-sep")?(d[s].separator=n.value,
35n.value=d[s].separator):n.classList.contains("ct-map-include")&&(d[s].isInclude=n.checked)}),(ee=e.mapBody)==null||ee.addEventListener("click",t=>{const n=t.target.closest(".ct-map-add");if(n){const l=Number(n.dataset.i),o=d[l];if(!o)return;const r={...o,isOriginal:!1,source:"",isInclude:!1};d.splice(l+1,0,r),f();return}const s=t.target.closest(".ct-map-del");if(s){const l=Number(s.dataset.i),o=d[l];if(!o||o.isOriginal!==!1)return;d.splice(l,1),f()}}),(te=e.btnClear)==null||te.addEventListener("click",()=>{j()}),(ne=e.btnSample)==null||ne.addEventListener("click",async()=>{i.trim()||(i=c==="vcf"?tt:c==="ics"?nt:Te,e.ta.value=i,D(),await L(),b())});function W(t){var s,l,o,r;const n=t==="text";(s=e.tabText)==null||s.classList.toggle("active",n),(l=e.tabFile)==null||l.classList.toggle("active",!n),(o=e.panelText)==null||o.classList.toggle("d-none",!n),(r=e.panelFile)==null||r.classList.toggle("d-none",n),xe({tabText:e.tabText,tabFile:e.tabFile,panelText:e.panelText,panelFile:e.panelFile,isText:n}),S||g(""),a={...a,columns:[]},m&&$(e.sqlBtns),t==="text"?(C=[],F(e.fileInput)):(i="",e.ta&&(e.ta.value="")),x(),f(),b()}(se=e.tabText)==null||se.addEventListener("click",()=>W("text")),(ae=e.tabFile)==null||ae.addEventListener("click",()=>W("file"));async function Ce(){const t=e.fileInput;if(!t)return;const n=t.files;if(C=n!=null&&n.length?[n[0]]:[],C[0]){if(C[0].size/1048576>pe){h(Je),C=[],F(e.fileInput),b();return}try{const l=await Oe(C[0]);l===""||l==null?(h(Ge),C=[],F(e.fileInput)):(i=l,e.ta&&(e.ta.value=l),D(),y=[],H(),R(),f(),await L())}catch{h("Could not read file"),C=[],F(e.fileInput)}}b()}e.fileInput&&e.fileZone&&Ue({input:e.fileInput,drop:e.fileZone,dragContainer:e.fileZone.closest(".card-body"),captionEl:e.fileDropCaption,onChange:()=>{Ce()}});const X=t=>{t.preventDefault();try{t.dataTransfer.dropEffect="copy"}catch{}};u.addEventListener("dragover",X,!0),u.addEventListener("drop",X,!0),(le=e.btnDownload)==null||le.addEventListener("click",()=>{var l,o;if(w){const r=(((l=e.fileName)==null?void 0:l.value)||"").trim()||I.replace(/\.[^.]+$/,"")||"converted",k=I.includes(".")?I.slice(I.lastIndexOf(".")+1):me(c);q.setSingle(w,r.includes(".")?r:`${r}.${k}`),q.runDownloadClick();return}const t=(((o=e.fileName)==null?void 0:o.value)||"").trim(),n=me(c),s=t?`${t}.${n}`:`converted.${n}`;we(T,s)}),m&&e.sqlBtns.forEach(t=>{t.addEventListener("click",()=>{const n=t.dataset.sqlMode;i.trim()&&he(n,e.sqlBtns)})}),m||(oe=e.btnConvert)==null||oe.addEventListener("click",()=>{i.trim()&&ge()}),A(),x(),f(),b()}export{Et as initCsvToolPage};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.