Weakly electric fish localize and identify objects by sensing distortions in a self-generated electric field. Fish can determine the resistance and capacitance of an object, for example, even though the field distortions being sensed are small and highly-dependent on object distance and size. Here we construct a model of the responses of the fish's electroreceptors on the basis of experimental data, and we develop a model of the electric fields generated by the fish and the distortions due to objects of different resistances and capacitances. This provides us with an accurate and efficient method for generating large artificial data sets simulating fish interacting with a wide variety of objects. Using these sets, we train an artificial neural network (ANN), representing brain areas downstream of electroreceptors, to extract the 3D location, size, and electrical properties of objects. The model performs best if the ANN operates in two stages: first estimating object distance and size and then using this information to extract electrical properties. This suggests a specific form of modularity in the electrosensory system that can be tested experimentally and highlights the potential of end-to-end modeling for studies of sensory processing.