czardas Posted October 4, 2010 Posted October 4, 2010 There's some very useful looking code in this thread. Good for some study. Thanks to all. operator64 ArrayWorkshop
taietel Posted October 4, 2010 Posted October 4, 2010 funkey, with your permission, I have added another thing in menu (Recent Files). It records 10 most recent files used. M.I.CSV-Editor V0.8.au3 Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text
guinness Posted April 7, 2011 Posted April 7, 2011 taietel some great Functions, But (sorry about that ) there is a potential problem with _CSV_FindDelimiter() in that if it Returns the Delimiter the File isn't closed!! So here is my attempt at the Function.Function:Func _CSV_FindDelimiter($sFileName) Local $aDelimiter = StringSplit(@TAB & "@,@;@,;@|@" & "'@" & '"', "@", 2), $aSRE Local $hFileOpen = FileOpen($sFileName, 0), $iIndex = 0, $iUbound = UBound($aDelimiter, 1), $sData If $hFileOpen = -1 Then Return SetError(1, 0, "") EndIf $sData = FileRead($hFileOpen) FileClose($hFileOpen) $aSRE = StringRegExp($sData, '(?s)(?i)(.*?)' & @CRLF, 3) If @error Then Return SetError(1, 0, "") EndIf If UBound($aSRE, 1) >= 2 Then $iIndex = 1 EndIf For $A = 0 To $iUbound - 1 If StringInStr($aSRE[0], $aDelimiter[$A]) <> 0 And StringInStr($aSRE[$iIndex], $aDelimiter[$A]) <> 0 Then Return $aDelimiter[$A] EndIf Next Return SetError(1, 0, "") EndFunc ;==>_CSV_FindDelimiter UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
taietel Posted April 8, 2011 Posted April 8, 2011 guinness, sorry for what? I'm glad you saw that mistake. Thanks! Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text
AZJIO Posted April 7, 2012 Posted April 7, 2012 (edited) funkeyWM_COMMAND - to hide the input field with a loss of focusproblem remains : if the scrolling ListView, the "Input" does not scroll.expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> Opt("GUIOnEventMode", 1) Global $aElement[2], $hActive, $iInput Global $iListView, $hListView, $dummy1, $dummy2 $hGUI = GUICreate('Double click on the item', 450, 360) GUISetOnEvent(-3, '_Exit') $iInput = GUICtrlCreateInput("", 0, 0, 0, 0) GUICtrlSetState(-1, $GUI_HIDE) $iListView = GUICtrlCreateListView('Col 1|Col 2', 5, 5, 440, 330, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_REPORT, $LVS_SHOWSELALWAYS)) $hListView = GUICtrlGetHandle(-1) For $i = 1 To 20 $item1 = Random(10, 99, 1) $item2 = '' For $j = 1 To 9 $item2 &= Chr(Random(97, 122, 1)) Next GUICtrlCreateListViewItem($item1 & '|' & $item2, $iListView) Next GUICtrlCreateButton('Button', 10, 340, 70, 20) $dummy1 = GUICtrlCreateDummy() GUICtrlSetOnEvent(-1, "_Exit") $dummy2 = GUICtrlCreateDummy() GUICtrlSetOnEvent(-1, "_SaveChange") Global $AccelKeys[2][2] = [["{ESC}", $dummy1],["{ENTER}", $dummy2]] GUISetAccelerators($AccelKeys) GUISetState() GUIRegisterMsg(0x4E, "_WM_NOTIFY") GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") ; to hide the input field with a loss of focus While 1 Sleep(100000) WEnd ; Displays Input element to the fore Func _GUICtrlListView_EditItem($hWnd, $iIndex, $iSubItem) ;funkey 19.02.2010 If $iIndex < 0 Then Return Local $aPos, $aRect, $iSum = 0 Local $x, $y, $w, $h For $i = 0 To $iSubItem - 1 $iSum += _GUICtrlListView_GetColumnWidth($hWnd, $i) Next $aRect = _GUICtrlListView_GetItemRect($hWnd, $iIndex) $aPos = ControlGetPos($hGUI, "", $hWnd) $x = $iSum + $aPos[0] + $aRect[0] $y = $aPos[1] + $aRect[1] $w = _GUICtrlListView_GetColumnWidth($hWnd, $iSubItem) $h = $aRect[3] - $aRect[1] GUICtrlSetPos($iInput, $x - 1, $y + 1, $w + 1, $h + 1) GUICtrlSetData($iInput, _GUICtrlListView_GetItemText($hWnd, $iIndex, $iSubItem)) GUICtrlSetState($iInput, $GUI_SHOW) GUICtrlSetState($iInput, $GUI_FOCUS) $aElement[0] = $iIndex $aElement[1] = $iSubItem EndFunc ; Save changes to the item Func _SaveChange() Local $sText = GUICtrlRead($iInput) If StringInStr($sText, @CR) Or StringInStr($sText, @LF) Then If StringLeft($sText, 1) <> '"' And StringInStr(StringMid($sText, 2, StringLen($sText) - 2), '"') Then $sText = StringReplace($sText, '"', "'") $sText = '"' & StringReplace($sText, '"', '') & '"' EndIf _GUICtrlListView_BeginUpdate($hActive) _GUICtrlListView_SetItemText($hActive, $aElement[0], $sText, $aElement[1]) GUICtrlSetState($iInput, $GUI_HIDE) _GUICtrlListView_SetColumnWidth($hListView, $aElement[1], -2) ;$LVSCW_AUTOSIZE_USEHEADER _GUICtrlListView_EndUpdate($hActive) Return $sText ; return text if you want to use it EndFunc Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView Switch $iCode Case $NM_DBLCLK ; Double click to edit ListView item Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) _GUICtrlListView_EditItem($hListView, DllStructGetData($tInfo, "Index"), DllStructGetData($tInfo, "SubItem")) $hActive = $hListView EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg Local $iIDFrom, $iCode $iIDFrom = BitAND($iwParam, 0xFFFF) ; LoWord $iCode = BitShift($iwParam, 16) ; HiWord Switch $iIDFrom Case $iInput Switch $iCode Case $EN_KILLFOCUS GUICtrlSetState($iInput, $GUI_HIDE) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func _Exit() Exit EndFunc Edited April 7, 2012 by AZJIO My other projects or all
MrCreatoR Posted October 21, 2012 Posted October 21, 2012 Very good work, but the script crashed when one of the columns is very large. It's crashed because of RegExp, here is an example: $vTest = '"' For $i = 1 To 5935 ;Change to 5934 and no crash $vTest &= '0' Next $vTest &= '"' $aRet = StringRegExp($vTest, '([^"])*', 3) ;Or change the pattern to '([^"]*)' ConsoleWrite("Result: " & $aRet[1] & @LF) Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
poolcat Posted August 25, 2015 Posted August 25, 2015 I tried to create some CSV functions. All files I checked were parsed wihtout errors: Edit: fixed a few errors in _ParseCSVHi Andy,Thanks for the good work!Theres a little thing in that could easily blow up the memory when working with large files. Change the last iteration in _parsecsv to this If $iSub = $iSubBound Then $iSubBound += 1 ReDim $aResult[int($iBound/$iSubBound)+1][$iSubBound] EndIfand all is good Cheers.
funkey Posted December 15, 2021 Author Posted December 15, 2021 Changed few things to run with actial version of AutoIt. Download in first post. Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now